c99 Designated Initializers work in clang++

struct foo {
        int a;
        int b;
};

const foo f = { .a = 10, .b = 11 };

Should not be work.
It cause error in gcc.
But compiled without warnings in clang++ 2.8

Hi;

struct foo {
int a;
int b;
};

const foo f = { .a = 10, .b = 11 };

clang trunk issues an error;

[~]> clang test.c
test.c:6:7: error: must use ‘struct’ tag to refer to type ‘foo’
const foo f = { .a = 10, .b = 11 };
^
struct
1 error generated.

Regards,
ismail

Yes, Clang supports designated initializers in C++ as an extension.

Note that the original question was about ‘clang++’ not ‘clang’, which is why omitting the ‘struct’ tag would be allowed.

There is a bug here, we don't emit an extwarn when -pedantic is specified.

-Chris

Fixed in Clang r123582.

Andrey, thanks for reporting this problem!

  - Doug

Hi;