Re: lcc-win32 conformance question



Lew Pitcher <lpitcher@xxxxxxxxxxxx> writes:

In comp.lang.c, teapot wrote:


If I compile this program

int main(void)
{
return 0; // foo bar baz
}

with

"lc -A -ansi89 foo.c"

(minus the quotes), no diagnostic is produced; but isn't this style of
comment illegal in C89

As I understand it, there is nothing in the C89 standard that explicitly
indicates that the C++-style // comment is illegal.

The syntax does. // is either a syntax error or the start of something
like 1//* divide? */2 which must be taken as an arithmetic
expression. I can't see what else it could be.

However, a compliant compiler is obliged to interpret the given line
// foo bar baz
as
a division token, followed by
a division token, followed by
an identifier token, followed by
an identifier token, followed by
an identifier token, followed by
a right brace bracket
which, of course, cannot be interpreted as a semantically correct C (C89)
statement. IIRC, a diagnostic should be emitted.

Yes, the cited example is just a syntax error, but we have no idea
what, if any, claims are made about the -ansi89 flag. Maybe it
implements some parts of ANSI 89 C? Unless that author says what is
should do, how can we anyone complain about what the compiler does?

--
Ben.
.



Relevant Pages

  • Re: MATLAB Compiler 4.6 Problems
    ... When I try to compile a file from MATLAB into a stand alone C++ ... 146 syntax error; found `void' expecting `;' ... Error libmatrix.cpp: 147 illegal statement termination ...
    (comp.soft-sys.matlab)
  • Re: C scripting (continued)
    ... The code will compile and run under windows and unix... ... And fix the memory leak that you ... This is a syntax error. ... A program that introduces syntax errors when it re-formats code ...
    (comp.lang.c)
  • Re: Is there an easy way to patch Nethack in XP?
    ... tried to compile that. ... syntax error before '->' token". ... the regex headers and libraries? ... I ran into some trouble with that previously due to Windows' parsing ...
    (rec.games.roguelike.nethack)
  • Re: Problem executing macros from global template
    ... use Tools> Compile and it will take you to the ... syntax error. ... Steve Hudson - Word Heretic ... It works before saving it as a template. ...
    (microsoft.public.word.vba.general)
  • RE: c89 problem w/ irrhfsu
    ... Subject: c89 problem w/ irrhfsu ... utility" and went to compile it per the instructions, ... the first time i've ever compiled ANYTHING in omvs, ...
    (bit.listserv.ibm-main)