http://llvm.org/bugs/show_bug.cgi?id=13492

             Bug #: 13492
           Summary: Explicitly defaulted constructors are not constexprs,
                    yet are treated as such for constant creation
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified


The following snippets should provide the same error, but don't in clang (ToT):

struct A {
};

struct B {
  B() = default;
};

struct C {
  C() {}  // Automatically gains constexpr since it qualifies
};

int main( void ) {
  const A a;  // Error
  const B b;  // Error
  const C c;  // OK
  return 0;
}

This is because:

dcl.fct.def.default/2:
An explicitly-defaulted function may be declared constexpr only if it would
have been implicitly declared as constexpr

and

class.ctor/5:
An implicitly-declared default constructor is an inline public member of its
class. 

class.ctor/6:
If that user-written default constructor would satisfy the requirements of a
constexpr constructor, the implicitly-defined default constructor is constexpr.

So only user-written default constructors gain automatic constexpr magic.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- 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