gcc - Is auto; a valid C translation unit? -
gcc - Is auto; a valid C translation unit? -
create file test.c, containing next code:
auto; compile clang 6.0: clang -c test.c. generate object file test.o, albeit 1 no actual content (other object file headers). prints warning, nonetheless accepts valid code:
test.c:1:1: warning: declaration not declare [-wmissing-declarations] auto; ^~~~ 1 warning generated. by contrast, gcc 4.9 refuses compile test.c, generating error:
test.c:1:1: error: 'auto' in file-scope empty declaration auto; ^ why clang generate warning yet take translation unit valid, while gcc generates error , refuses compile it? behaviour more conforming c standards? point of allowing auto declaration declares nothing?
it not valid code. implementation free give meaning wants after issuing diagnostic message.
5.1.1.3 diagnostics1 conforming implementation shall produce @ to the lowest degree 1 diagnostic message (identified in implementation-defined manner) if preprocessing translation unit or translation unit contains violation of syntax rule or constraint, if behavior explicitly specified undefined or implementation-defined. diagnostic messages need not produced in other circumstances.9) [...]
6.7 declarationsconstraints 2 declaration other static_assert declaration shall declare @ to the lowest degree declarator (other parameters of function or members of construction or union), tag, or members of enumeration. [...]
quotes c99+amendments (c11, n1570)
c gcc clang
Comments
Post a Comment