This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49924] New: [C++0X] [constexpr] can't initialize a non-static member array of a literal type as a constexpr
- From: "faisalv at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 31 Jul 2011 15:56:59 +0000
- Subject: [Bug c++/49924] New: [C++0X] [constexpr] can't initialize a non-static member array of a literal type as a constexpr
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49924
Summary: [C++0X] [constexpr] can't initialize a non-static
member array of a literal type as a constexpr
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: faisalv@yahoo.com
I believe the following code should compile:
struct A { constexpr A() { } };
struct B {
A array[1]; //non-static member array of a literal type w constexpr ctor
constexpr B() : array{} { } // here is the problem
};
int main()
{
constexpr B b{}; // won't compile
}
But i get the following output with g++4.6.1:
<output>
In function 'int main()':
<file>.cpp:11:17: error: '{{{A()}}}' is not a constant expression
</output>
FYI, the following does compile:
int main() { constexpr A a[1]{}; }
Thanks!
p.s
My gcc -v output is:
Using built-in specs.
COLLECT_GCC=g++-4.6.1
COLLECT_LTO_WRAPPER=/usr/local/gcc4.6.1/libexec/gcc/i686-pc-linux-gnu/4.6.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.6.1/configure --prefix=/usr/local/gcc4.6.1
--enable-generated-files-in-srcdir --enable-threads=posix --with-system-zlib
--enable-__cxa_atexit --disable-checking --disable-nls --enable-bootstrap
--with-gcc --with-gnu-as --with-gnu-ld --disable-multilib
Thread model: posix
gcc version 4.6.1 (GCC)