Q: Precendence rules and lambda expressions I am trying to understand the difference in warning gives by gcc-4.3.2 and
gcc-4.5.1.
Given
struct S { };

int main() {
  int** i;
  i = new  int*[10] ; delete[] i; // [1a]
  i = new (int*[10]); delete[] i; // [1b]

  S** s;
  s = new  S*[10];   // [2a] fine
  s = new (S*[10]); // [2b] warning: lambda expressions only available with -std=c++0x or -std=gnu++0x
}

I understand that [1a] and [2a] correctly initialize a dynamic array of
pointers with the pointers being uninitialized.
We have instances of [2b] in our codebase where somebody actually wanted
[2a]. With the better C++0x support in gcc-4.5.1 [2b] suddenly triggers a
warning.
My question is, what would [2b] actually do in C++0x? And what is the
difference to [1b] which appears fine in gcc-4.5.1? Was [2b] doing the
correct thing with gcc-4.3.2 and C++03?
PS. I know of STL containers.

A: The warning is a bug: the expression cannot be mistaken as a lambda expression; It would do the same thing with --std=c++0x defined.
See also 


*

*http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46159

*C++ array creation problem specific to gcc 4.5
I tested with gcc v 4.3,4.4,4.5 and 4.6. Only 4.5 gives the rogue warning, 4.6 happily compiles the code without complaint.
Edit: exact versions tested


*

*gcc version 4.3.5 (Ubuntu 4.3.5-3ubuntu1) 

*gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) 

*gcc version 4.5.1 (Ubuntu/Linaro 4.5.1-7ubuntu2) warns

*gcc version 4.6.1 20110604 (prerelease) (Debian 4.6.0-11) 


Update I just proved that the compiled output of the 4.5.1 compiler (and all of the other versions, for that matter) is exactly identical whether or not you specified --std=c++0x on the command line by doing
g++ -o 5-0x.s --std=c++0x -S test.cpp
g++ -o 5.s    -S             test.cpp

Comparing 5-0x.s and 5.s shows no difference whatsoever.
