[llvm-bugs] [Bug 26271] New: erroneous error of circular inheritance

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 23 08:44:22 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26271

            Bug ID: 26271
           Summary: erroneous error of circular inheritance
           Product: clang
           Version: 3.7
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hui.li at me.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

I could be wrong but I don't think the following code has circular inheritance.
And gcc6 compiles it just fine.

#include <type_traits>
#include <utility>

enum color
{
   red,
   green,
   yellow
};

enum shape
{
   circle,
   square
};

template < color... c >
using colors = std::integer_sequence<color,c...>;

template < shape... s >
using shapes = std::integer_sequence<shape,s...>;

template < color, shape >
struct object
{};

template < typename, typename >
struct objects;

template < color c, shape s >
struct objects<colors<c>,shapes<s>>
 : object<c,s>
{};

template < color c, shape... s >
struct objects<colors<c>,shapes<s...>>
 : object<c,s>...
{};

template < color... c, shape... s >
struct objects<colors<c...>, shapes<s...>>
 : objects<colors<c>,shapes<s...>>...
{};

int main(int argc, const char * argv[])
{
   objects<colors<red,green>,shapes<circle>> x;
   object<red,circle>& r = x;
   (void)r;
}


clang++-mp-3.7 -std=c++1z main.cpp
main.cpp:42:4: error: circular inheritance between 'objects<colors<c>,
shapes<s...> >' and 'objects<integer_sequence<color,
      c...>, integer_sequence<shape, s...> >'
 : objects<colors<c>,shapes<s...>>...
   ^

-- 
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/20160123/092c3cd7/attachment.html>


More information about the llvm-bugs mailing list