[LLVMbugs] [Bug 2412] New: GCC warning is a clang error
Neil Booth
neil at daikokuya.co.uk
Wed Jun 4 07:25:09 PDT 2008
bugzilla-daemon at cs.uiuc.edu wrote:-
> For this code:
>
> $ cat t.c
> void bar() {
> char ng;
>
> welcome(ng);
> }
>
> void welcome(new_game)
> char new_game;
> {
> foo(new_game);
> }
>
> clang produces this:
>
> $ clang -emit-llvm-bc -x c -o t.o t.c
> t.c:7:6: error: conflicting types for 'welcome'
> void welcome(new_game)
> ^
> t.c:4:3: error: previous implicit declaration is here
> welcome(ng);
> ^
> 2 diagnostics generated.
>
> While GCC produces this:
>
> $ gcc -o t t.c -c
> t.c:8: warning: conflicting types for ‘welcome’
> t.c:4: warning: previous implicit declaration of ‘welcome’ was here
This is undefined behaviour in C90 and a constraint violation in C99.
It is a good thing that compilers other than GCC reject this kind of
shoddy code. It doesn't take much to fix the code, whatever it was
actually intended to mean.
I believe more modern compilers should strive to far higher goals than
"accept anything invalid just because GCC does", except perhaps in a
well-documented GCC compatibility mode. Even GCC doesn't strive to
achieve that w.r.t. prior versions; every release is stricter in
various areas than the prior one even for C.
Neil.
More information about the llvm-bugs
mailing list