Create a test.c file containing the following code:
auto;
Compile it with clang 6.0: clang -c test.c It will successfully generate the test.o object file, although without the actual contents (except for the headers of the object files). It prints a warning, but nonetheless accepts this as a valid code:
test.c:1:1: warning: declaration does not declare anything [-Wmissing-declarations] auto; ^~~~ 1 warning generated.
Unlike gcc 4.9, it refuses to compile test.c , generating an error:
test.c:1:1: error: 'auto' in file-scope empty declaration auto; ^
Why does clang generate a warning, but this translation unit is considered valid, and gcc generates an error and refuses to compile it? Whose behavior is more in line with C standards? What is the point of an automatic ad that declares nothing?
source share