[LLVMbugs] [Bug 11614] New: Cannot assign in constexpr initialization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Dec 19 02:04:08 PST 2011


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

             Bug #: 11614
           Summary: Cannot assign in constexpr initialization
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: max at duempel.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


struct Foo {};constexpr Foo foo = Foo();

constexpr.cc:1:29: error: constexpr variable 'foo' must be initialized by a
constant expression

The assignment should be allowed, because the value of Foo() is known at
compile time (it doesn't make a difference if I make the struct non-empty and
add an explicit constexpr constructor, by the way).

The following works:

struct Foo {};constexpr Foo foo();

This problem occurs with libstdc++ 4.6 in allocator.h:

  struct allocator_arg_t { };
  constexpr allocator_arg_t allocator_arg = allocator_arg_t();

svn trunk 146862

-- 
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.



More information about the llvm-bugs mailing list