clang allow the _Alignof operator being applied to a function type?

Hi, all!

C11 6.5.3.4/p1 says:
    "The _Alignof operator shall not be applied to a function type or an incomplete type."

But I compiled the following code with clang-3.4 and gcc-4.9 on linux (x86_64):

Clang trunk reports:

test.c:3:13: error: invalid application of ‘alignof’ to an incomplete type ‘struct S’
int b = _Alignof(struct S);
^ ~~~~~~
test.c:3:29: note: forward declaration of ‘struct S’
int b = _Alignof(struct S);
^

Hi, Nikola!

I known "_Alignof(struct S)" will cause error, and I mean why "_Alignof(void(int))" not cause clang to report error.

C11 6.5.3.4/p1 says:
"The _Alignof operator shall not be applied to a function type or an incomplete type."
                           ^^^^^^^^^ ^^^^^^^^^^^^^

Sandy Zhang

These are enabled as language extension and will produce an error if you pass -pedantic to clang. There might be another, more fine-grained, switch that controls these.

_Alignof(void(int)) produces: invalid application of alignof to a function type

_Alignof(void) produces: invalid application of alignof to a void type

These are enabled as language extension and will produce an error if you
pass -pedantic to clang. There might be another, more fine-grained, switch
that controls these.

_Alignof(void(int)) produces: invalid application of alignof to a function
type
_Alignof(void) produces: invalid application of alignof to a void type

Function types and void have size 1 and alignment 1 as a GNU extension.

(Hmm, we really should add that -fno-gnu-extensions flag one day...)

[…]