home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 243,128 of 243,242   
   Tim Rentsch to Keith Thompson   
   Re: "A diagram of C23 basic types"   
   02 Feb 26 09:34:26   
   
   From: tr.17687@z991.linuxsc.com   
      
   Keith Thompson  writes:   
      
   > Tim Rentsch  writes:   
   >   
   >> Keith Thompson  writes:   
   >>   
   >>> Tim Rentsch  writes:   
   >>> [...]   
   >>>   
   >>>> Trailing commas in argument lists and/or parameter lists   
   >>>> could be accepted as an extension, even without giving a   
   >>>> diagnostic as I read the C standard, but implementations   
   >>>> are certainly within their rights to reject them.   
   >>>   
   >>> I believe a diagnotic is required.   
   >>>   
   >>> C17 5.1.1.3:   
   >>>   
   >>>     A conforming implementation shall produce at least one   
   >>>     diagnostic message (identified in an implementation-defined   
   >>>     manner) if a preprocessing translation unit or translation   
   >>>     unit contains a violation of any syntax rule or constraint,   
   >>>     even if the behavior is also explicitly specified as undefined   
   >>>     or implementation-defined.   
   >>>   
   >>> A trailing comma on an argument or parameter list is a violation   
   >>> of a syntax rule.   
   >>   
   >> I believe a diagnostic is not required, because the C standard   
   >> explicitly allows extensions.  If such diagnostics were required   
   >> even for constructions that are part of extensions, then there is no   
   >> reason to allow extensions, because whatever behavior is desired   
   >> could be done anyway, under the freedom granted by undefined   
   >> behavior.  It would be stupid to explicitly grant permission to do   
   >> something if it could be done anyway without the permission.  And   
   >> the people who wrote the C standard are not stupid.   
   >   
   > I believe that the fact that a conforming implementation provides an   
   > extension does not relieve it of its responsibility to diagnose syntax   
   > errors and constraint violations.   
   >   
   > The authors of both gcc and clang appear to agree.  A concrete example:   
   > gcc has an extension (which clang also provides) allowing the middle   
   > operand of a conditional operator to be omitted, so that `x ? : y` is   
   > equivalent to `x ? x : y`, except that x is evaluated only once.   
   >   
   > By default, use of this extension (which would be a syntax   
   > error if the extension did not exist) is not diagnosed;  neither   
   > compiler is conforming by default.  With "-std=c17 -pedantic" or   
   > "-std=c17 -pedantic-errors", both issue a warning or error message,   
   > respectively.   
      
   Your logic is bad.  First the diagnostics are produced only because   
   you have asked them to be produced by giving the -pedantic option.   
   Second there are other cases where diagnostics are not given even   
   with -pedantic.  Third the statement that without -pedantic the   
   compilers are not conforming does not mean that their behavior in   
   any particular case is not conforming;  the argument implicitly uses   
   circular logic, using the non-issuance of a diagnostic to imply that   
   the compilers are not conforming, but whether a conforming   
   implmentation must issue a diagnostic is the question being   
   considered.   
      
   It doesn't make sense for the C standard to include a statement that   
   extensions are allowed if they would be allowed anyway.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca