[Bug c++/57694] New: [c++11] constexpr constructor do not work with const address of own member
lts-rudolph at gmx dot de
gcc-bugzilla@gcc.gnu.org
Mon Jun 24 08:02:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57694
Bug ID: 57694
Summary: [c++11] constexpr constructor do not work with const
address of own member
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lts-rudolph at gmx dot de
The following code results in
error: field initializer is not constant
class A
{
private:
int a;
const int* const aptr;
public:
constexpr A( int _a):
a(_a)
, aptr( &a) // why aptr could not be initialized?
{}
};
class Data { } d1;
class B
{
private:
Data* dptr1;
public:
constexpr B(Data* _p): dptr1( _p) {}
};
class Use
{
static constexpr A a{2}; // fail! error: field initializer is not
constant
static constexpr B b{&d1}; // works
};
More information about the Gcc-bugs
mailing list