[llvm-bugs] [Bug 39263] New: Clang wrongly reports duplicate member error on using recursive template
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 12 08:07:27 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39263
Bug ID: 39263
Summary: Clang wrongly reports duplicate member error on using
recursive template
Product: clang
Version: 7.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: leandro.dasilva at younicos.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181012/655397ea/attachment.html>
More information about the llvm-bugs
mailing list