[LLVMbugs] [Bug 7954] New: Clang erronously compiles double initialization of const static int

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 20 21:36:28 PDT 2010


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

           Summary: Clang erronously compiles double initialization of
                    const static int
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: prasoonsaurav.nit at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


The following program erronously compiles on Clang

class Prasoon{

  static const int dummy = 0;

};
int const Prasoon::dummy = 0;

int main(){}

According to C++-03 (Section 9.4.2-3)

If a static data member is of const literal type, its declaration in the class
definition can specify a brace-or- equal-initializer in which every
initializer-clause that is an assignment-expression is a constant expression. A
static data member of literal type can be declared in the class definition with
the constexpr specifier; if so, its declaration shall specify a
brace-or-equal-initializer in which every initializer-clause that is an
assignment-expression is a constant expression. [ Note: In both these cases,
the member may appear in constant expressions. — end note ] The member shall
still be defined in a namespace scope if it is used in the program and the
namespace scope definition shall not contain an initializer.


More discussion here :
http://stackoverflow.com/questions/3531296/have-i-found-a-bug-in-clang

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