lcc-win32 conformance question

Discussion in 'C Programming' started by teapot, Apr 26, 2008.

  1. teapot

    teapot Guest

    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 and thus this piece of code should be invalid?

    How standards conformant is (unnamed compiler)?
     
    teapot, Apr 26, 2008
    #1
    1. Advertising

  2. teapot

    Ian Collins Guest

    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 and thus this piece of code should be invalid?
    >
    > How standards conformant is (unnamed compiler)?
    >

    Why are you asking on a C++ group?

    --
    Ian Collins.
     
    Ian Collins, Apr 26, 2008
    #2
    1. Advertising

  3. teapot

    Ian Collins Guest

    Ian Collins wrote:
    > 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 and thus this piece of code should be invalid?
    >>
    >> How standards conformant is (unnamed compiler)?
    >>

    > Why are you asking on a C++ group?
    >

    Oops, I buggered that up, wrong group open...

    --
    Ian Collins.
     
    Ian Collins, Apr 26, 2008
    #3
  4. teapot

    Bartc Guest

    "teapot" <> wrote in message
    news:...
    >
    > 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 and thus this piece of code should be invalid?
    >
    > How standards conformant is (unnamed compiler)?


    You mean, the unnamed compiler called lcc-win32?

    Well, I couldn't get an error message from it. Neither from using
    DigitalMars DMC -A.

    GCC of course complained, but then with it's 10000 options it would be odd
    if it missed that one.

    Sorry I didn't have any more command-line compilers to try..

    I guess some are strictly conformant are some aren't. Perhaps there should
    be a certificate issued to conformant ones to stop you absentmindedly
    sneaking in a // comment or two!

    --
    bartc
     
    Bartc, Apr 26, 2008
    #4
  5. teapot <> writes:

    > 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 and thus this piece of code should be invalid?


    If the compiler claims conformance to the obvious standard when passed
    that flag then it is in error. Of course, just passing flag means
    nothing. Does the documentation claim conformance to C90 (= ANSI C89)?

    > How standards conformant is (unnamed compiler)?


    Do you mean lcc-win32? If so, I have found problems with compound
    literals, VLA parameters, complex numbers and designated initialisers
    so some of the C99 parts are a bit rough round the edges. There have
    been a few other reports of conformance issues, but they may well have
    been fixed. For example, it used to consider long * and int * to be
    compatible types.

    It is probably fair to say the standards conformance is not a top
    priority for that compiler.

    --
    Ben.
     
    Ben Bacarisse, Apr 26, 2008
    #5
  6. teapot

    jacob navia Guest

    Ian Collins wrote:
    > 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 and thus this piece of code should be invalid?
    >>
    >> How standards conformant is (unnamed compiler)?
    >>

    > Why are you asking on a C++ group?
    >


    Because pissing lcc-win is his favorite spot, like my cat
    that pisses everywhere even in my computer!



    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Apr 26, 2008
    #6
  7. teapot

    santosh Guest

    jacob navia wrote:

    > Ian Collins wrote:
    >> 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 and thus this piece of code should be
    >>> invalid?
    >>>
    >>> How standards conformant is (unnamed compiler)?
    >>>

    >> Why are you asking on a C++ group?
    >>

    >
    > Because pissing lcc-win is his favorite spot, like my cat
    > that pisses everywhere even in my computer!


    In any case is what the OP claims true? Are there command-line switches
    to get a diagnostic for C++ style comments when compiler in strict C90
    mode?

    PS. I think you should cool down a little and not give these anonymous
    posters much weightage (except if they do uncover a real issue in
    lcc-win). Even your prose has started suffering.
     
    santosh, Apr 26, 2008
    #7
  8. "teapot" <> schreef in bericht
    news:...
    >
    > 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 and thus this piece of code should be invalid?
    >
    > How standards conformant is (unnamed compiler)?


    oh no it accepts C++ style comments!!
    really, who cares!!

    >
     
    Serve Laurijssen, Apr 26, 2008
    #8
  9. teapot

    santosh Guest

    Serve Laurijssen wrote:

    >
    > "teapot" <> schreef in bericht
    > news:...
    >>
    >> 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 and thus this piece of code should be
    >> invalid?
    >>
    >> How standards conformant is (unnamed compiler)?

    >
    > oh no it accepts C++ style comments!!
    > really, who cares!!


    Anyone who wants to compile the same code under a strictly C90
    conforming mode on another compiler which does reject C++ style
    comments as syntax errors. All is well if that compiler happens to have
    a switch to make it specifically accept this comment style while
    retaining strict C90 conformance in all other respects, but most
    compilers don't have such fine-grained control. You'll probably need to
    compile the code under either C99 conformance (which in turn may not
    even be available), or in some other "relaxed" mode which might accept
    other non-C90 constructs that would otherwise have been diagnosed.
     
    santosh, Apr 26, 2008
    #9
  10. teapot

    Guest

    On Apr 25, 7:17 pm, Ben Bacarisse <> wrote:
    > teapot <> writes:
    > > 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 and thus this piece of code should be invalid?

    >
    > If the compiler claims conformance to the obvious standard when passed
    > that flag then it is in error.


    Why is it an error? A C90 compiler can reject that program,
    that's clear; but why does it have to?

    Yevgen
     
    , Apr 26, 2008
    #10
  11. teapot

    Guest

    On Apr 26, 6:37 am, santosh <> wrote:
    > jacob navia wrote:
    > > Ian Collins wrote:
    > >> 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 and thus this piece of code should be
    > >>> invalid?

    >
    > >>> How standards conformant is (unnamed compiler)?

    >
    > >> Why are you asking on a C++ group?

    >
    > > Because pissing lcc-win is his favorite spot, like my cat
    > > that pisses everywhere even in my computer!

    >
    > In any case is what the OP claims true? Are there command-line switches
    > to get a diagnostic for C++ style comments when compiler in strict C90
    > mode?
    >
    > PS. I think you should cool down a little and not give these anonymous
    > posters much weightage (except if they do uncover a real issue in
    > lcc-win). Even your prose has started suffering.


    Jacob certainly should not overreact, he harms himself with
    that. But you should admit that all the posters assumed
    that the given issue is a non-conformance bug, yet nobody
    said why it is so. Or at least nobody said that it was *not*
    a conformance bug, which effectively is the same thing as
    agreeing that it was (comp.lang.c - best resource for newbies,
    all mistakes corrected, etc.)

    Yevgen
     
    , Apr 27, 2008
    #11
  12. teapot

    Lew Pitcher Guest

    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.

    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.



    > and thus this piece of code should be invalid?
    >
    > How standards conformant is (unnamed compiler)?


    --
    Lew Pitcher

    Master Codewright & JOAT-in-training | Registered Linux User #112576
    http://pitcher.digitalfreehold.ca/ | GPG public key available by request
    ---------- Slackware - Because I know what I'm doing. ------
     
    Lew Pitcher, Apr 27, 2008
    #12
  13. teapot

    Flash Gordon Guest

    wrote, On 26/04/08 23:37:
    > On Apr 25, 7:17 pm, Ben Bacarisse <> wrote:
    >> teapot <> writes:
    >>> 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 and thus this piece of code should be invalid?

    >> If the compiler claims conformance to the obvious standard when passed
    >> that flag then it is in error.

    >
    > Why is it an error? A C90 compiler can reject that program,
    > that's clear; but why does it have to?


    Having produced a diagnostic it is allowed to produce an executable.
    However, // is a syntax error so a diagnostic is required. Arrantly none
    is produced by lcc-win32 in C89 conforming mode.

    I would expect this to be an easy bug for Jacob to fix, all he has to do
    is check what mode the compiler is in once he has detected the // and
    produce an appropriate diagnostic.
    --
    Flash Gordon
     
    Flash Gordon, Apr 27, 2008
    #13
  14. writes:

    > On Apr 25, 7:17 pm, Ben Bacarisse <> wrote:
    >> teapot <> writes:
    >> > 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 and thus this piece of code should be invalid?

    >>
    >> If the compiler claims conformance to the obvious standard when passed
    >> that flag then it is in error.

    >
    > Why is it an error? A C90 compiler can reject that program,
    > that's clear; but why does it have to?


    Because it contains a syntax error. It need not reject it, but a
    diagnostic is required. The "error" is that the compiler is silent.

    As I said (in snipped text) I have no idea if the -ansi89 flag does
    what one might guess it does. As far as I can see lcc-win32 accepts
    all kinds of stuff that require a diagnostic when seen by a C90
    compiler. Unless someone says what the -ansi89 flag *should* do we
    must be silent.

    --
    Ben.
     
    Ben Bacarisse, Apr 27, 2008
    #14
  15. Lew Pitcher <> 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.
     
    Ben Bacarisse, Apr 27, 2008
    #15
  16. teapot

    Guest

    On Apr 26, 6:50 pm, Ben Bacarisse <> wrote:
    > writes:
    > > On Apr 25, 7:17 pm, Ben Bacarisse <> wrote:
    > >> teapot <> writes:
    > >> > 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 and thus this piece of code should be invalid?

    >
    > >> If the compiler claims conformance to the obvious standard when passed
    > >> that flag then it is in error.

    >
    > > Why is it an error? A C90 compiler can reject that program,
    > > that's clear; but why does it have to?

    >
    > Because it contains a syntax error. It need not reject it, but a
    > diagnostic is required. The "error" is that the compiler is silent.


    Actually what I wanted was the reference to the standard,
    and I found it (surprisingly, it's where "diagnostic"is
    defined). I have always thought that syntax extensions are
    allowed, that's why I insisted on "why?". E.g. I was sure
    that gcc doesn't have to warn about __attribute__ even in
    conforming mode. Now I have a question about conformance
    of one unnamed compiler:

    >>> cat ex.i

    __attribute__((unused)) static int a;
    >>> gcc -c -W -Wall -pedantic -ansi ex.i
    >>>


    Is this unnamed compiler non-conforming?

    Yevgen
     
    , Apr 27, 2008
    #16
  17. teapot

    Guest

    On Apr 26, 7:07 pm, wrote:
    > On Apr 26, 6:50 pm, Ben Bacarisse <> wrote:
    >
    >
    >
    > > writes:
    > > > On Apr 25, 7:17 pm, Ben Bacarisse <> wrote:
    > > >> teapot <> writes:
    > > >> > 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 and thus this piece of code should be invalid?

    >
    > > >> If the compiler claims conformance to the obvious standard when passed
    > > >> that flag then it is in error.

    >
    > > > Why is it an error? A C90 compiler can reject that program,
    > > > that's clear; but why does it have to?

    >
    > > Because it contains a syntax error. It need not reject it, but a
    > > diagnostic is required. The "error" is that the compiler is silent.

    >
    > Actually what I wanted was the reference to the standard,
    > and I found it (surprisingly, it's where "diagnostic"is
    > defined). I have always thought that syntax extensions are
    > allowed, that's why I insisted on "why?". E.g. I was sure
    > that gcc doesn't have to warn about __attribute__ even in
    > conforming mode. Now I have a question about conformance
    > of one unnamed compiler:
    >
    > >>> cat ex.i

    >
    > __attribute__((unused)) static int a;
    >
    > >>> gcc -c -W -Wall -pedantic -ansi ex.i


    It seems "greater than" signs are mangled somehow,
    the above should read

    $$$ cat ex.i
    __attribute__((unused)) static int a;
    $$$ gcc -c -W -Wall -pedantic -ansi ex.i
    $$$

    I.e. no diagnostics is emitted when compiling
    a file consisting of one line

    __attribute__((unused)) static int a;

    Yevgen
     
    , Apr 27, 2008
    #17
  18. In article <c881a$4813b36e$cef8bf02$-Free>,
    Lew Pitcher <> wrote:

    >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.


    It can't even be *parsed* as a C89 program, because it does not match
    the grammar. It's a syntactic error, not a semantic one.

    -- Richard
    --
    :wq
     
    Richard Tobin, Apr 27, 2008
    #18
  19. teapot

    Chris Torek Guest

    In article <>
    <> wrote:
    >Actually what I wanted was the reference to the standard,
    >and I found it (surprisingly, it's where "diagnostic"is
    >defined). I have always thought that syntax extensions are
    >allowed, that's why I insisted on "why?". E.g. I was sure
    >that gcc doesn't have to warn about __attribute__ even in
    >conforming mode. Now I have a question about conformance
    >of one unnamed compiler [which does not complain about a

    translation unit consisting entirely of the one line]
    >__attribute__((unused)) static int a;
    >
    >Is this unnamed compiler non-conforming?


    Not from this example. The reason is that names prefixed with
    various kinds of underscores (including single underscores followed
    by uppercase, and double underscores) are reserved to the
    implementation, and once you use an "implementation keyword", the
    entire "contract", as it were, that the Standard provides to the
    C programmer is terminated, at least in principle.

    Thus, the following does not require a diagnostic:

    #pragma comment !
    ! hi there.
    static int a;

    because "#pragma" can also do pretty much anything (although in
    C99 there are now standardized #pragma operations). (Perhaps, as
    in this case, the "#pragma" turns "!" into a comment-to-end-of-line
    character. "#pragma fortran" might be used to switch to Fortran
    code, which would change the syntax even more.)

    This is, of course, the danger of doing anything that departs from
    Standard C: the moment you abandon the standard, even for an instant,
    the standard can abandon you, possibly "forever". :) Of course,
    real, reasonable C implementations do not do so: they disable
    "complete standard-ness" long enough for you to useful work, while
    retaining "enough standard-ness" long enough for you to, well, do
    useful work. However, for reasons both good and bad, these may
    lure you into doing things that, in effect, "capture" you into
    staying with that particular compiler-vendor "forever". This in
    turn may be good (lets you get your work done in a reasonable way
    and timely fashion, for instance) or bad (costs you a million
    dollars every five minutes, for instance), or possibly both.
    --
    In-Real-Life: Chris Torek, Wind River Systems
    Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
    email: gmail (figure it out) http://web.torek.net/torek/index.html
     
    Chris Torek, Apr 27, 2008
    #19
  20. writes:

    > On Apr 26, 7:07 pm, wrote:
    >> On Apr 26, 6:50 pm, Ben Bacarisse <> wrote:

    <snip>
    >> > Because it contains a syntax error. It need not reject it, but a
    >> > diagnostic is required. The "error" is that the compiler is silent.

    >>
    >> Actually what I wanted was the reference to the standard,
    >> and I found it (surprisingly, it's where "diagnostic"is
    >> defined). I have always thought that syntax extensions are
    >> allowed,


    You may be right (about syntax extensions) but I doubt it. In any
    case, // can't be an extension in any useful sense since

    >> that's why I insisted on "why?". E.g. I was sure
    >> that gcc doesn't have to warn about __attribute__ even in
    >> conforming mode. Now I have a question about conformance
    >> of one unnamed compiler:
    >>
    >> __attribute__((unused)) static int a;


    I think gcc should issue a diagnostic here in a conforming mode. What
    that means is that the only way to invoke gcc in conforming mode is
    to add "-D__attribute__(x)=\\" to the gcc command :)

    OK, the smiley shows I am not entirely serious, but there is a serious
    point here. The illegal __attribute__ syntax is easy to either remove
    or flag as an error (as I did above) whereas adding // as an extension
    is impossible to correct. Some correct programs will be rejected (for
    example

    int main(void) { return 1//**/2; }

    ) or some syntax errors will go un-remarked on.

    --
    Ben.
     
    Ben Bacarisse, Apr 27, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wagner Dias
    Replies:
    3
    Views:
    3,086
    Andre Kostur
    Mar 28, 2005
  2. jacob navia

    lcc-win32

    jacob navia, Oct 8, 2004, in forum: C Programming
    Replies:
    102
    Views:
    2,643
    Keith Thompson
    Oct 22, 2004
  3. vittorio

    Weird lcc-win32 behaviour

    vittorio, Dec 11, 2005, in forum: C Programming
    Replies:
    14
    Views:
    2,220
    Vittorio
    Dec 13, 2005
  4. Tea Pot
    Replies:
    55
    Views:
    1,328
    James Kuyper
    Jun 7, 2009
  5. Tea Pot
    Replies:
    5
    Views:
    263
Loading...

Share This Page