No, no, no...

What you have in your code is a _hard_ _solid_ _error_ in C language. More 
pedantically, it is a _constraint_ _violation_ - a specific kind of problem, 
which makes your code flat out invalid and requires a diagnostic message 
from your compiler. 

Remember, that we do not have concepts of "warnings" or "errors" in C 
language. We only have a concept of "diagnostic message". When a C compiler 
encounters a constraint violation it is required to issue a diagnostic 
message. _Any_ diagnostic message. What the message actually says does not 
matter ("warning" or "error" - does not matter). Whether the compilation 
is aborted after that message does not matter either. However, once such 
message is issued, your code no longer qualifies as a valid C program.

So, if your compiler decided to issue a "warning" for this code, it is just 
a quirk of your compiler or a quirk of your specific compiler setup. Your 
compiler just happens to be set up to report [some] hard errors as mere 
"warnings" (and to continue translation of the code). Formally, the 
compiler is not is the wrong here, since issuing _any_ diagnostic 
message is sufficient to meet the standard requirements.

However, under such compiler setup it becomes your responsibility 
to catch such "warnings" and realize that they are not mere "warnings" (as 
you seem to incorrectly believe), but rather hard errors.

Alternatively, if you want the compiler to help you with this and report 
hard errors as "errors", you might try supplying '-pedantic-errors' flag 
as part of its configuration (at least in case of GCC or Clang). The 
very purpose of this flag is to force the compiler to report language errors 
as "error" messages (and abort compilation). It is not always perfect, but 
it might be of use if you care to write your code in pedantically 
correct standard C language.

Now, if (as you claim) Intel C compiler compiles this code completely 
silently, it would indicate either that Intel compiler is broken or 
that someone forcefully configured it into some awfully non-compliant 
mode. Either way, a compiler that issues no diagnostic message for a 
constraint violation is not a compliant C compiler. (BTW, are you sure you 
are compiling the code as C and not as C++?)

–– 
Best regards,
Andrey

Reply via email to