<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang wrongly reports duplicate member error on using recursive template"
   href="https://bugs.llvm.org/show_bug.cgi?id=39263">39263</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang wrongly reports duplicate member error on using recursive template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>leandro.dasilva@younicos.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I am using Clang 7.0 on Windows 10, but could reproduce the issue on Compiler
Explorer using different compiler versions.

The following code compiles fine on GCC (tested with 4.2 (!) and 4.8 and other
versions available on Compiler Explorer), and on MSVC 19 (again on CE).

But yields error on every clang I tried, both on my local machine as well as on
Compiler Explorer.

The code requires boost (tested with 1.52 and newer)

Code:

```
#include <boost/mpl/integral_c.hpp>

struct r_base {};

typedef long long r_value_t;

template<r_value_t N, r_value_t D = 1>
struct r : r_base
{
    static const r_value_t n = N;
    static const r_value_t d = D;
};

template<r_value_t X>
struct a : boost::mpl::integral_c<r_value_t, (X < 0) ? -X : X> {};

template<r_value_t U, r_value_t V>
struct g : g<V, U % V> {};

template<r_value_t U>
struct g<U, 0> : a<U> {};

template<typename T>
struct r_r
{
    static const r_value_t n = a<T::n>::value;
    static const r_value_t d = a<T::d>::value; // error happens here: d is
duplicate member
    static const r_value_t g = g<n, d>::value;
};

Clang reports the errors:
<source>:29:37: error: duplicate member 'd'

    static const r_value_t g = g<n, d>::value;

                                    ^
<source>:28:28: note: previous declaration is here

    static const r_value_t d = a<T::d>::value;

                           ^
<source>:29:38: error: expected ';' at end of declaration list

    static const r_value_t g = g<n, d>::value;

                                     ^
                                     ;

```

Thank you in advance.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>