This article is within the scope of WikiProject C/C++, a collaborative effort to improve the coverage of C/C++ on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
What's the problem with the last snippet? The statement is incorrect: that code compiles even in pre-C++0x compliant compilers. Dgutson (talk) —Preceding undated comment added 19:38, 15 April 2009 (UTC).
It does, but according to the standard it is ill-formed. The reason for this is the wording of [basic.defs.odr]/2: "An expression is potentially evaluated unless it appears where an integral constant expression is required ... An object or non-overloaded function is used if its name appears in a potentially-evaluated expression". According to this, the static data member is clearly used in the example. Furthermore, "Every program shall contain exactly one definition of every non-inline function or object that is used in that program; no diagnostic required", in essence, even if it is ill-formed, the compiler does not have to warn about it, but the resulting program has undefined behaviour. decltype (talk) 20:25, 15 April 2009 (UTC)