https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78359
Eric Gallager <egall at gwmail dot gwu.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egall at gwmail dot gwu.edu --- Comment #6 from Eric Gallager <egall at gwmail dot gwu.edu> --- (In reply to Andrew Pinski from comment #4) > (In reply to hugo74 from comment #2) > > It should not work that way. I checked it in other C compilers and each of > > them reports an redefinition error in such case. > > Are you sure they were C compilers and not C++ compilers? > > C and C++ differ here. Hence -Wc++-compat gets the warning desired: $ /usr/local/bin/gcc -Wall -Wextra -pedantic -Wredundant-decls -Wc++-compat -fno-common -c pr78359.c pr78359.c:1:14: warning: duplicate declaration of ‘Counter’ is invalid in C++ [-Wc++-compat] int Counter, Counter, Counter; ^~~~~~~ pr78359.c:1:5: note: previous declaration of ‘Counter’ was here int Counter, Counter, Counter; ^~~~~~~ pr78359.c:1:23: warning: duplicate declaration of ‘Counter’ is invalid in C++ [-Wc++-compat] int Counter, Counter, Counter; ^~~~~~~ pr78359.c:1:14: note: previous declaration of ‘Counter’ was here int Counter, Counter, Counter; ^~~~~~~