// comments

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Flash Gordon

    #16
    Re: // comments

    jacob navia wrote, On 27/04/08 11:05:
    Flash Gordon wrote:
    >jacob navia wrote, On 27/04/08 08:59:
    >>Richard Heathfield wrote:
    >>>When invoked in conforming mode, Microsoft C (or at least my copy of
    >>>it) issues the necessary diagnostic message if you use // in an
    >>>erroneous syntactical context.
    >>>
    >>D:\lcc\mc71\t est>type tt.c
    >>// aaaaa
    >>>
    >>D:\lcc\mc71\t est>cl -W4 tt.c
    >>Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64
    >>Copyright (C) Microsoft Corporation. All rights reserved.
    >>>
    >>tt.c
    >>tt.c(2) : warning C4206: nonstandard extension used : translation
    >>unit is empty
    >>>
    >>Of course your version dates from 1991... Always the same word games,
    >>half truths, etc. Pure regulars BS.
    >>
    >Not at all. You have just demonstrated that what Richard said is true
    >for the version you have as well. The compiler emitted a diagnostic.
    >There is no requirement for it to produce an error or abort the
    >translation. I have already posted saying that all you have to do is
    >detect it and issue a warning, as has Keith.
    >
    word games, word games
    No, statements of fact.
    // aaaaaaa
    int a=0;
    >
    Now, cl doesn't give any warning:
    D:\lcc\mc71\tes t>cl -W4 -c tt.c
    Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x6
    Copyright (C) Microsoft Corporation. All rights reserved.
    >
    tt.c
    >
    D:\lcc\mc71\tes t>
    >
    WORD GAMES as always.
    You are the one playing word games. You know very well that if MS VC++
    is invoked in conforming more it *does* produce a diagnostic for //
    style comments. That is does not when *not* in conforming mode is *not*
    an excuse for your compiler to fail to produce required diagnostics in a
    claimed C89 conforming mode.

    Also MS VCC++ not producing a diagnostic in non-conforming mode does not
    contradict what Richard says above.

    Either accept that on your compiler -ansi89 does not make it conforming
    (which would seem strange to me but it's your choice) or accept that you
    have a bug. Do not try and use the non-conforming mode of other
    compilers as an excuse if you are attempting to provide a conforming mode.
    --
    Flash Gordon

    Comment

    • santosh

      #17
      Re: // comments

      Ben Bacarisse wrote:
      ymuntyan@gmail. com writes:
      >
      >On Apr 27, 4:26 am, Flash Gordon <s...@flash-gordon.me.ukwro te:
      >>jacob navia wrote, On 27/04/08 08:59:
      <snip>
      >>If you state that -ansi89 does *not* mean conformance to C89 (or C90
      >>or C95) then as has already been stated it is allowed to accept
      >>whatever you want. If I was one of your paying customers I would not
      >>be happy, but I'm not.
      >>
      >Perhaps that customer wanted warnings for stuff which
      >reduces portability, like variadic macros not understood
      >by MS compiler?
      >
      Then they would be disappointed. I am not sure to what extent it is
      either wise or topical to go into details but -ansi89 does not
      diagnose variadic macros (as it should). Fortunately, the
      implementation of them seems to be broken so the user would likely
      find out if they tried to use them. It seems that -ansi89 also
      permits long long int, treats restrict as a keyword, does not diagnose
      the use of compound literals, permits [static N] in function
      parameters... I stopped looking after a while[1].
      >
      Its use for checking portability would be rather limited, I think.
      >
      [1] To be balanced, it does diagnose some non ANSI C constructs.
      Maybe jacob implemented -ansi89 switch as a synonym for -ansi?

      Comment

      • Richard Heathfield

        #18
        Re: // comments

        jacob navia said:
        Richard Heathfield wrote:
        <snip>
        >When invoked in conforming mode, Microsoft C (or at least my copy of it)
        >issues the necessary diagnostic message if you use // in an erroneous
        >syntactical context.
        >>
        >
        >
        D:\lcc\mc71\tes t>type tt.c
        // aaaaa
        >
        D:\lcc\mc71\tes t>cl -W4 tt.c
        Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64
        Copyright (C) Microsoft Corporation. All rights reserved.
        >
        tt.c
        tt.c(2) : warning C4206: nonstandard extension used : translation unit
        is empty
        >
        Of course your version dates from 1991... Always the same word games,
        half truths, etc. Pure regulars BS.
        Firstly, even a conforming implementation is only obliged to issue *one*
        diagnostic message for any translation unit that violates any syntactic
        rules or constraints, and the form of that message is up to the
        implementation. If a translation unit contains two or more such
        violations, an implementation only need diagnose one of them. In that
        respect, your log does not prove that MS C violates conformance by not
        producing the diagnostic message you'd like to see - by producing one at
        all, it conforms.

        Secondly, you have not even invoked it in conforming mode!

        It seems that you are determined to fail to understand the point being made
        here. Now try adding the -Za switch to your invocation, to instruct MS C
        to disable language extensions. Then give it a translation unit that
        contains no other violations of syntactic rules or constraints - for
        example:

        #include <stdio.h>

        int main(void)
        {
        puts("Hello, world!"); // this is a syntax error
        return 0;
        }

        If you call this translation unit tt.c and invoke Microsoft C in conforming
        mode as follows:

        cl -W4 -Za tt.c

        what diagnostic messages do you get?

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

        Comment

        • Ben Bacarisse

          #19
          Re: // comments

          santosh <santosh.k83@gm ail.comwrites:
          Ben Bacarisse wrote:
          <snip>
          >>Perhaps that customer wanted warnings for stuff which
          >>reduces portability, like variadic macros not understood
          >>by MS compiler?
          >>
          >Then they would be disappointed.
          <snip>
          >[1] To be balanced, it does diagnose some non ANSI C constructs.
          >
          Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
          Sorry, I don't follow.

          --
          Ben.

          Comment

          • Harald van =?UTF-8?b?RMSzaw==?=

            #20
            Re: // comments

            On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
            santosh <santosh.k83@gm ail.comwrites:
            >Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
            >
            Sorry, I don't follow.
            With GCC, -ansi means that valid C90 programs will be accepted, but
            invalid C90 programs, complete with syntax errors and/or constraint
            violations, will not necessarily be rejected. It's possible that jacob
            navia made -ansi89 behave the same way in lcc-win32.

            Comment

            • Bartc

              #21
              Re: // comments


              "Ben Bacarisse" <ben.usenet@bsb .me.ukwrote in message
              news:87ej8s5ep6 .fsf@bsb.me.uk. ..
              jacob navia <jacob@nospam.c omwrites:
              >
              >Recently we had poor Mr "teapot" that was horrified at the heresy
              >of lcc-win of accepting // comments.
              >
              Can you clear up the question of what the -ansi89 flag is intended to
              do? Your compiler is allowed to accept any extensions it likes and to
              reject and conforming C90 programs it wishes to *unless* you claim that
              lc -ansi89 is intended to be a conforming C90 implementation. What is
              the purpose of -ansi89?
              >
              >C is a nice language, and you can do anything with it, inclusive a
              >program that transforms // comments into well behaved /* ... */
              >ones...
              >
              How do you do that with:
              >
              int main(void) { return 1//* divide? */2; }
              >
              Is this a valid C90 program or an incorrect C90 one that has a //
              comment int it?
              I think it's more of a problem of the design of the // comment convention,
              in that this ambiguity can occur.

              I would guess that in the case of Jacob's code, it's assuming input is of a
              file where // can legally occur. It will translate that into a form that
              will give a compilation error (in any mode). Then the user can trace back
              and see immediately where the problem is.

              That's no different from feeding this code to practically any compiler that
              by default accepts // comments; it will report an error and the user can
              either invoke conforming mode or (more sensibly so that it gives no further
              problems) turn // into / /).

              For Jacob's code to work sensibly, it would need a switch to tell it the
              input has pure C90-conforming comments, but if someone knew that, there
              would be no need to run the program!

              --
              Bartc


              Comment

              • Ben Bacarisse

                #22
                Re: // comments

                Harald van Dijk <truedfx@gmail. comwrites:
                On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                >santosh <santosh.k83@gm ail.comwrites:
                >>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                >>
                >Sorry, I don't follow.
                >
                With GCC, -ansi means that valid C90 programs will be accepted, but
                invalid C90 programs, complete with syntax errors and/or constraint
                violations, will not necessarily be rejected. It's possible that jacob
                navia made -ansi89 behave the same way in lcc-win32.
                I considered that meaning, but since santosh was replying to a message
                that stated that -ansi89 treats restrict as a keyword, that did not
                seem like a reasonable interpretation.

                --
                Ben.

                Comment

                • santosh

                  #23
                  Re: // comments

                  Ben Bacarisse wrote:
                  Harald van D?k <truedfx@gmail. comwrites:
                  >
                  >On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                  >>santosh <santosh.k83@gm ail.comwrites:
                  >>>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                  >>>
                  >>Sorry, I don't follow.
                  >>
                  >With GCC, -ansi means that valid C90 programs will be accepted, but
                  >invalid C90 programs, complete with syntax errors and/or constraint
                  >violations, will not necessarily be rejected. It's possible that
                  >jacob navia made -ansi89 behave the same way in lcc-win32.
                  >
                  I considered that meaning, but since santosh was replying to a message
                  that stated that -ansi89 treats restrict as a keyword, that did not
                  seem like a reasonable interpretation.
                  Yes. The lcc-win manual that I have indicates that the -ansi switch
                  makes the compiler conform to C99. Your post up-thread which seemed to
                  indicate that lcc-win accepted several C99 constructs when
                  under -ansi89 suggested to me that jacob might have simply made -ansi89
                  a synonym for -ansi with a few more check (presumably whatever his
                  paying customer asked for) added in. This would mean that -ansi89 isn't
                  really suitable for making lcc-win conform to C90. This is also borne
                  out by the fact that the -ansi89 switch isn't listed in the lcc-win
                  manual I have here.

                  Comment

                  • Harald van =?UTF-8?b?RMSzaw==?=

                    #24
                    Re: // comments

                    On Sun, 27 Apr 2008 18:52:20 +0530, santosh wrote:
                    Ben Bacarisse wrote:
                    >Harald van D?k <truedfx@gmail. comwrites:
                    >>On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                    >>>santosh <santosh.k83@gm ail.comwrites:
                    >>>>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                    >>>>
                    >>>Sorry, I don't follow.
                    >>>
                    >>With GCC, -ansi means that valid C90 programs will be accepted, but
                    >>invalid C90 programs, complete with syntax errors and/or constraint
                    >>violations, will not necessarily be rejected. It's possible that jacob
                    >>navia made -ansi89 behave the same way in lcc-win32.
                    >>
                    >I considered that meaning, but since santosh was replying to a message
                    >that stated that -ansi89 treats restrict as a keyword, that did not
                    >seem like a reasonable interpretation.
                    >
                    Yes. The lcc-win manual that I have indicates that the -ansi switch
                    makes the compiler conform to C99. [...]
                    Interesting. I still happened to have the Linux version of lcc installed,
                    and it doesn't support any -ansi option, but does support the -ansi89
                    option.

                    Warning 0 Ignoring unknown option '-ansi'

                    Because of that, I didn't consider the possibility of an lcc option -ansi
                    since added.

                    Comment

                    • santosh

                      #25
                      Re: // comments

                      Harald van D?k wrote:
                      On Sun, 27 Apr 2008 18:52:20 +0530, santosh wrote:
                      >Ben Bacarisse wrote:
                      >>Harald van D?k <truedfx@gmail. comwrites:
                      >>>On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                      >>>>santosh <santosh.k83@gm ail.comwrites:
                      >>>>>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                      >>>>>
                      >>>>Sorry, I don't follow.
                      >>>>
                      >>>With GCC, -ansi means that valid C90 programs will be accepted, but
                      >>>invalid C90 programs, complete with syntax errors and/or constraint
                      >>>violations , will not necessarily be rejected. It's possible that
                      >>>jacob navia made -ansi89 behave the same way in lcc-win32.
                      >>>
                      >>I considered that meaning, but since santosh was replying to a
                      >>message that stated that -ansi89 treats restrict as a keyword, that
                      >>did not seem like a reasonable interpretation.
                      >>
                      >Yes. The lcc-win manual that I have indicates that the -ansi switch
                      >makes the compiler conform to C99. [...]
                      >
                      Interesting. I still happened to have the Linux version of lcc
                      installed, and it doesn't support any -ansi option, but does support
                      the -ansi89 option.
                      >
                      Warning 0 Ignoring unknown option '-ansi'
                      >
                      Because of that, I didn't consider the possibility of an lcc option
                      -ansi since added.
                      I too still have the aborted Linux version installed, but the
                      information above was taken from the installation lcc-win32 under WINE.

                      Comment

                      • Ben Bacarisse

                        #26
                        Re: // comments

                        "Bartc" <bc@freeuk.comw rites:
                        "Ben Bacarisse" <ben.usenet@bsb .me.ukwrote in message
                        news:87ej8s5ep6 .fsf@bsb.me.uk. ..
                        >jacob navia <jacob@nospam.c omwrites:
                        >>
                        >>Recently we had poor Mr "teapot" that was horrified at the heresy
                        >>of lcc-win of accepting // comments.
                        >>
                        >Can you clear up the question of what the -ansi89 flag is intended to
                        >do? Your compiler is allowed to accept any extensions it likes and to
                        >reject and conforming C90 programs it wishes to *unless* you claim that
                        >lc -ansi89 is intended to be a conforming C90 implementation. What is
                        >the purpose of -ansi89?
                        >>
                        >>C is a nice language, and you can do anything with it, inclusive a
                        >>program that transforms // comments into well behaved /* ... */
                        >>ones...
                        >>
                        >How do you do that with:
                        >>
                        >int main(void) { return 1//* divide? */2; }
                        >>
                        >Is this a valid C90 program or an incorrect C90 one that has a //
                        >comment int it?
                        >
                        I think it's more of a problem of the design of the // comment convention,
                        in that this ambiguity can occur.
                        That is true. The supposition made by the utility is that the above
                        program needs fixing. The problem I cite is really only a problem for
                        a "C90 compiler with // comments". Such a compiler needs to choose
                        between the interpretations .

                        --
                        Ben.

                        Comment

                        • Ben Bacarisse

                          #27
                          Re: // comments

                          Harald van Dijk <truedfx@gmail. comwrites:
                          On Sun, 27 Apr 2008 18:52:20 +0530, santosh wrote:
                          >Ben Bacarisse wrote:
                          >>Harald van D?k <truedfx@gmail. comwrites:
                          >>>On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                          >>>>santosh <santosh.k83@gm ail.comwrites:
                          >>>>>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                          >>>>>
                          >>>>Sorry, I don't follow.
                          >>>>
                          >>>With GCC, -ansi means that valid C90 programs will be accepted, but
                          >>>invalid C90 programs, complete with syntax errors and/or constraint
                          >>>violations , will not necessarily be rejected. It's possible that jacob
                          >>>navia made -ansi89 behave the same way in lcc-win32.
                          >>>
                          >>I considered that meaning, but since santosh was replying to a message
                          >>that stated that -ansi89 treats restrict as a keyword, that did not
                          >>seem like a reasonable interpretation.
                          >>
                          >Yes. The lcc-win manual that I have indicates that the -ansi switch
                          >makes the compiler conform to C99. [...]
                          >
                          Interesting. I still happened to have the Linux version of lcc installed,
                          and it doesn't support any -ansi option, but does support the -ansi89
                          option.
                          >
                          Warning 0 Ignoring unknown option '-ansi'
                          >
                          Because of that, I didn't consider the possibility of an lcc option -ansi
                          since added.
                          It hasn't been added. I think santosh is referring to the -ansic flag.

                          --
                          Ben.

                          Comment

                          • Flash Gordon

                            #28
                            Re: // comments

                            Harald van Dijk wrote, On 27/04/08 13:42:
                            On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                            >santosh <santosh.k83@gm ail.comwrites:
                            >>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                            >Sorry, I don't follow.
                            >
                            With GCC, -ansi means that valid C90 programs will be accepted, but
                            invalid C90 programs, complete with syntax errors and/or constraint
                            violations, will not necessarily be rejected. It's possible that jacob
                            navia made -ansi89 behave the same way in lcc-win32.
                            I believe that on lcc-win32 -ansic selects C99 conformance (modulo bugs
                            and bits not implemented). So if -ansi99 was a synonym for -ansic it
                            would also select C99 conformance and thus allow // comments, treat
                            restrict as a keyword etc.
                            --
                            Flash Gordon

                            Comment

                            • Ben Bacarisse

                              #29
                              Re: // comments

                              santosh <santosh.k83@gm ail.comwrites:
                              Ben Bacarisse wrote:
                              >
                              >Harald van D?k <truedfx@gmail. comwrites:
                              >>
                              >>On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
                              >>>santosh <santosh.k83@gm ail.comwrites:
                              >>>>Maybe jacob implemented -ansi89 switch as a synonym for -ansi?
                              >>>>
                              >>>Sorry, I don't follow.
                              >>>
                              >>With GCC, -ansi means that valid C90 programs will be accepted, but
                              >>invalid C90 programs, complete with syntax errors and/or constraint
                              >>violations, will not necessarily be rejected. It's possible that
                              >>jacob navia made -ansi89 behave the same way in lcc-win32.
                              >>
                              >I considered that meaning, but since santosh was replying to a message
                              >that stated that -ansi89 treats restrict as a keyword, that did not
                              >seem like a reasonable interpretation.
                              >
                              Yes. The lcc-win manual that I have indicates that the -ansi switch
                              You mean -ansic yes?
                              makes the compiler conform to C99. Your post up-thread which seemed to
                              indicate that lcc-win accepted several C99 constructs when
                              under -ansi89 suggested to me that jacob might have simply made -ansi89
                              a synonym for -ansi with a few more check (presumably whatever his
                              paying customer asked for) added in.
                              No. It does, for example stop inline being a keyword and stops
                              declarations being mixed with statements.
                              This would mean that -ansi89 isn't
                              really suitable for making lcc-win conform to C90. This is also borne
                              out by the fact that the -ansi89 switch isn't listed in the lcc-win
                              manual I have here.
                              Jacob seems to be saying that it is a custom flag for one particular
                              purpose. As such, it seems that lcc-win32 has no C90/C89 conforming
                              mode and the specific tests made when -ansi89 are given were selected
                              by a customer and don't have much to do with the standard.

                              --
                              Ben.

                              Comment

                              • santosh

                                #30
                                Re: // comments

                                Ben Bacarisse wrote:
                                santosh <santosh.k83@gm ail.comwrites:
                                [ ... ]
                                >Yes. The lcc-win manual that I have indicates that the -ansi switch
                                >
                                You mean -ansic yes?
                                Sorry yes. Time for another cup of tea. :-)
                                >makes the compiler conform to C99. Your post up-thread which seemed
                                >to indicate that lcc-win accepted several C99 constructs when
                                >under -ansi89 suggested to me that jacob might have simply made
                                >-ansi89 a synonym for -ansi with a few more check (presumably
                                >whatever his paying customer asked for) added in.
                                >
                                No. It does, for example stop inline being a keyword and stops
                                declarations being mixed with statements.
                                Okay, but if it is intended to be a generally usable option then jacob
                                needs to do more work.
                                >This would mean that -ansi89 isn't
                                >really suitable for making lcc-win conform to C90. This is also borne
                                >out by the fact that the -ansi89 switch isn't listed in the lcc-win
                                >manual I have here.
                                >
                                Jacob seems to be saying that it is a custom flag for one particular
                                purpose. As such, it seems that lcc-win32 has no C90/C89 conforming
                                mode and the specific tests made when -ansi89 are given were selected
                                by a customer and don't have much to do with the standard.
                                This is my impression too. Also if (as it seems to me) jacob has not
                                documented the -ansi89 switch anywhere, and it was meant only for a
                                specific customer, I wonder how the OP stumbled on it. I guess he just
                                happened to use -ansi89 and saw that it was accepted.

                                It would be helpful if jacob could clarify things further, perhaps in
                                comp.compilers. lcc.

                                Comment

                                Working...