[Bug c++/66109] New: defining constexpr objects without initializer
vgheorgh at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon May 11 16:36:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66109
Bug ID: 66109
Summary: defining constexpr objects without initializer
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vgheorgh at gmail dot com
Target Milestone: ---
The following code
struct Foo
{
constexpr Foo() = default;
};
int main()
{
constexpr Foo foo;
}
should not compile. Unfortunately it compiles with all g++ versions (that
support c++11) up to and including 5.1
>From [decl.constexpr]:
A constexpr specifier used in an object declaration declares the object as
const. Such an object shall have literal type and shall be initialized.
Therefore the correct way of usage should be
constexpr Foo foo{};
More information about the Gcc-bugs
mailing list