[cfe-dev] Address of compound literal (-std=gnu++0x)
Allan Odgaard
691D2C6C-B023-46A5-B1D7-ACCBA4713A87 at uuid-mail.com
Wed May 18 08:55:43 PDT 2011
The code below is C99 and supported by GCC in C++ mode since they allow
C99 features.
Clang accepts the code in C99 mode, it (correctly) says that compound
literals are a C99-specific feature in C++ mode, but with -std=gnu++0x
(which should support GCC extensions, i.e. C99) I get the following
error:
error: taking the address of a temporary object of type 'struct
point' [-Waddress-of-temporary]
----------8<----------
struct point { int x; int y; };
void draw_point (struct point const* aPoint) { }
int main (int argc, char const* argv[])
{
draw_point(&(struct point){ 1, 2 });
return 0;
}
More information about the cfe-dev
mailing list