Skip to content

Instantly share code, notes, and snippets.

@phst
Created March 27, 2012 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phst/2220810 to your computer and use it in GitHub Desktop.
Save phst/2220810 to your computer and use it in GitHub Desktop.
Brace initialization bug
void foo() {
new int[1] {1};
}
template<int A>
void goo() {
new int[1] {1};
}
int main() {
foo();
goo<1>();
}
@phst
Copy link
Author

phst commented Mar 27, 2012

The above code produces an error with G++ 4.7:

g++-4.7 -Wall -Wextra -std=c++11 b.cpp 
b.cpp: In instantiation of 'void goo() [with int A = 1]':
b.cpp:12:10:   required from here
b.cpp:7:3: error: parenthesized initializer in array new [-fpermissive]
b.cpp:7: confused by earlier errors, bailing out

Commenting out the instantiation of goo removes the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment