Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with constexpr(gcc) - error: a brace-enclosed initializer is not allowed here before '{' token

struct X {
constexpr static char a1[] = "hello"; // Okay
constexpr static const char* a2[] = {"hello"}; // Error
};

int main(){}

Compiling with gcc gives the error:

error: a brace-enclosed initializer is not allowed here before '{' token

Is this an illegal use of constexpr?

EDIT

I tried 3 different versions of gcc, and it compiled on the newest 4.7.0 I have (I just downloaded it, I'm using mingw-w64), so it looks to be a fixed bug (a link to the bug would be nice though!).

4.7.0 20120311 (prerelease) // Okay
4.6.4 20120305 (prerelease) // Error
4.7.0 20110829 (experimental) // Error

like image 250
Jesse Good Avatar asked Mar 28 '12 02:03

Jesse Good


1 Answers

This is a bug which has been fixed. I have confirmed that the code compiles with g++ 4.7.0 20120311 (prerelease).

like image 171
Jesse Good Avatar answered Oct 28 '22 08:10

Jesse Good