c99 Designated Initializers work in clang++

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

c99 Designated Initializers work in clang++

Andrey Valyaev
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

--
        http://mdf-i.blogspot.com
        Andrey Valyaev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

İsmail Dönmez
Hi;

On Sun, Jan 16, 2011 at 12:37 AM, Andrey Valyaev <[hidden email]> wrote:
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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

Chandler Carruth
In reply to this post by Andrey Valyaev
On Sat, Jan 15, 2011 at 2:37 PM, Andrey Valyaev <[hidden email]> wrote:
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

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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

Chandler Carruth
In reply to this post by İsmail Dönmez
On Sat, Jan 15, 2011 at 2:40 PM, İsmail Dönmez <[hidden email]> wrote:
Hi;

On Sun, Jan 16, 2011 at 12:37 AM, Andrey Valyaev <[hidden email]> wrote:
struct foo {
       int a;
       int b;
};

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

clang trunk issues an error;

[~]> clang test.c

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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

Chris Lattner
In reply to this post by Andrey Valyaev

On Jan 15, 2011, at 2:37 PM, Andrey Valyaev wrote:

> 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

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

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

Douglas Gregor

On Jan 15, 2011, at 4:34 PM, Chris Lattner wrote:

>
> On Jan 15, 2011, at 2:37 PM, Andrey Valyaev wrote:
>
>> 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
>
> There is a bug here, we don't emit an extwarn when -pedantic is specified.

Fixed in Clang r123582.

Andrey, thanks for reporting this problem!

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: c99 Designated Initializers work in clang++

İsmail Dönmez
In reply to this post by Chandler Carruth
Hi;

On Sun, Jan 16, 2011 at 2:11 AM, Chandler Carruth <[hidden email]> wrote:
On Sat, Jan 15, 2011 at 2:40 PM, İsmail Dönmez <[hidden email]> wrote:
Hi;

On Sun, Jan 16, 2011 at 12:37 AM, Andrey Valyaev <[hidden email]> wrote:
struct foo {
       int a;
       int b;
};

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

clang trunk issues an error;

[~]> clang test.c

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

My bad! Sorry.

ismail


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev