public
Created

Brace initialization bug

  • Download Gist
gistfile1.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13
void foo() {
new int[1] {1};
}
 
template<int A>
void goo() {
new int[1] {1};
}
 
int main() {
foo();
goo<1>();
}

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.