Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Is this valid C? Date: Mon, 20 Feb 2017 13:50:44 -0800 Organization: None to speak of Lines: 58 Message-ID: References: <87shnab3c5.fsf@bsb.me.uk> <87wpclaoqs.fsf@bsb.me.uk> <4a1d176e-0c60-422e-9eb0-04574b2f32ef@googlegroups.com> <9e683fb3-c692-4777-8e58-6ab23eee68ff@googlegroups.com> <726ddfc8-83af-47db-8a18-08d921816e82@googlegroups.com> <3bee4191-6834-4b99-bf92-d8ca5b8b34e2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="9029eb194d173f90c26f49eb1843bbfe"; logging-data="24003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+fDR1qdWAixa0TPl7MSq4" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:wPBb2A8WgV09rZ8FUpUOboYJNEw= sha1:P8XpHi//QhUoiX60aIWIAuNNNlo= Xref: csiph.com comp.lang.c:104294 supercat@casperkitty.com writes: > On Monday, February 20, 2017 at 2:28:05 PM UTC-6, Keith Thompson wrote: >> supercat writes: >> > The Standard would regard any program that uses such a feature as >> > "non-conforming" >> >> No, it would fit within the Standard's (very weak) definition of the >> term "conforming program". > > I thought that conforming programs were required to be well formed if they > don't contain any #pragma directives or reserved identifiers for which the > Standard defines no meaning. Why did you think that, and what exactly does "well formed" mean? (The C++ standard uses the term "well-formed"; the C standard does not.) By definition (N1570 4p7): A *conforming program* is one that is acceptable to a conforming implementation. > Otherwise, any source file could be turned > into a conforming program with the aid of an "implementation" which checks > whether it matches some hard-coded reference file, outputs a hard-coded > executable if so, and otherwise feeds the program to a "real" implementation. Yes, that is what the standard's definition of "conforming program" implies. It's not a particularly useful concept as far as I can tell. I think I've read that it was added to the standard (it appears in C90) for political reasons. There's some discussion in the ANSI C Rationale, https://www.lysator.liu.se/c/rat/a.html#1-7 . >> > and would mandate that any conforming implementation >> > output a diagnostic upon receipt of such a construct, even if the >> > implementation supported the feature in question. >> >> Yes. So use the compiler in non-conforming mode if you want to use the >> extension. > > That would be possible, but for whatever reason compiler writers have been > extremely loath to extend the language via any means other than by defining > reserved identifiers--among other things because they have no way of knowing > whether any syntax they decide to use might be given an incompatible meaning > by a future standard. Saying "a compiler may either accept X and give it a > certain meaning, or reject X" would suggest that future standards would be > unlikely to give X a contrary meaning. Most of the extensions provided by gcc are not defined in that way. I'm less familiar with extensions provided by other compilers. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"