Re: what is the output of this program?



Three Headed Monkey said:

<snip>

You are ignoring third warning.

The third warning, as originally reported, was a single apostrophe, and
that's fairly easy to ignore.

If I add prototype for main like below,
compiler only issues one warning

#include <stdio.h>
void main(int argc, char **argv)
{
int C = 0;
printf("C %s C++\n", C == C++ ? "==" : "!=");
}

$ make foo9.exe
lc -ansic -pedantic -A -shadows -unused -O -c foo9.c -o foo9.obj
Warning foo9.c: 3 '

I note that the single apostrophe remains even here. I'm not sure what "lc"
means by this apostrophe, but it's a legal diagnostic message. Perhaps it
means "this code is so screwed I just give up on the whole thing", which
would at least make sense.

Error foo9.c: 3 compiler error in d:\lcc\mc71\types.c--assertion failure
at line 868 Error c:\tmp\clc\foo9.c 3 Compiler error (trap). Stopping
compilation 1 error
make: *** [foo9.obj] Error 1

Perhaps there is bug.

Perhaps there is, but you haven't shown this. The cited program exhibits
undefined behaviour, so the implementation is allowed to do anything it
likes with it - and since I don't see any syntax errors or constraint
violations, I see no requirement for any message whatsoever. For the
compiler to have a bug that is relevant to the above code, it would surely
have to be exhibiting (or harbouring) some inappropriate behaviour when
given that code. But since the Standard allows all behaviours for such
code, it is hard to see how it could be used to demonstrate a bug in the
implementation.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: Visual C++ 7.1 INTERNAL COMPILER ERROR
    ... minimalised the code that causes the bug. ... The bug is that the following syntax causes an Internal Compiler Error. ... class SomeClassA, and the code compiles with "warning C4183: 'SomeClassA': ...
    (comp.lang.cpp)
  • Re: Initialising Variables
    ... colleagues started telling me it was bad practice and that the compiler ... should be left to spot the use of uninitilised variables and hence ... flags -Wall, etc., are still there, I just don't get the warning messages). ... (and standard doesn't forbid this so it's not a bug). ...
    (comp.lang.c)
  • Re: bug with ifort + openmp : allocatable array not allocated after allocation
    ... So: a clear compiler bug. ... subprogram, an allocated allocatable array without the save attribute ... the above line produced the following warning: ...
    (comp.lang.fortran)
  • Re: what is the output of this program?
    ... Warning foo.c: 1 ' ... Any time a compiler dies with an internal error (in this case, ... still a bug, at least as I use the word "bug". ... 1 multiple use of 'int' ...
    (comp.lang.c)
  • Re: what is the output of this program?
    ... compiler only issues one warning ... I note that the single apostrophe remains even here. ... int main ...
    (comp.lang.c)