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

            Bug ID: 23906
           Summary: clang compiles invalid multiple inheritance code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

This fails to compile with gcc and EDG but compiles with clang:

#include <type_traits>                                                          
#include <utility>                                                              
#include <cassert>                                                              

template <class Tag, class Value>                                               
class Pack                                                                      
{                                                                               
 public:                                                                        
  Pack(const Value& value) : _value(value) {}                                   
  Value value() const { return _value; }                                        
private:                                                                        
  Value _value;                                                                 
};                                                                              

template<class Tag, class Value>                                                
decltype(auto) unpack(Tag, Pack<Tag, Value>& pack) {                            
  return pack.value();                                                          
}                                                                               

struct tag1 {};                                                                 
struct tag2 {};                                                                 

struct A3 : Pack<tag1, int>, Pack<tag2, double> {                               
  A3(int x, double y) : Pack<tag1, int>(x), Pack<tag2, double>(y) {}            
};                                                                              

int main() {                                                                    
  A3 a3(1, 2);                                                                  
  assert(unpack(tag1(), a3) == 1);                                              
  assert(unpack(tag2(), a3) == 2);                                              
}     

Per discussion on stackoverflow 

http://stackoverflow.com/questions/30814981/will-this-template-function-correctly-match-a-class-with-multiple-bases

it looks like a compiler bug with clang

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to