Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: "...the value becomes,indeterminate each time the declaration is reached" Date: Mon, 11 Feb 2019 13:43:43 -0800 Organization: None to speak of Lines: 39 Message-ID: References: <30065f8f-0b5b-4d17-846f-4fa63051cd0e@googlegroups.com> <9d6896dc-a369-4eb0-a93c-c0317a19908e@googlegroups.com> <7615cc12-0e98-4917-a0d0-682c7aeabeb5@googlegroups.com> <8736oze00i.fsf@bsb.me.uk> <3f4afc9e-c532-4ee1-93f6-d6872c55928c@googlegroups.com> <87h8debdlm.fsf@bsb.me.uk> <6cc27732-6b74-4503-88e6-e0b991615a2a@googlegroups.com> <875ztub1vq.fsf@bsb.me.uk> <87ftsva8o7.fsf@bsb.me.uk> <62e2da0a-0d2d-49d5-8535-8ebf922eb014@googlegroups.com> <87a7j39ho4.fsf@bsb.me.uk> <75fe55ac-a651-454a-a1c4-5d63a290b1cb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="6590b15d36b268306aee2c0ce6043287"; logging-data="1291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RWM/Qms1XSYSSMIC1vdFV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:pchbxGt3L/etKYQP9hWG77sr0Fg= sha1:YPe0iT00O0IOph6abrOHQXxsKac= Xref: csiph.com comp.lang.c:140863 Malcolm McLean writes: [...] > One characteristic of undefined behaviour in C is that the program text > has an error in it. > Of course we can call the program text "grammatical" if by that we mean > "accepted by the C compiler", and that's a legitimate use of the word. That's not what most of us mean by "grammatical". A C compiler can accept any input that doesn't include a #error directive after translation phase 4 -- including inputs that violate the syntax in Annex A. Malcolm, will you at least acknowledge that most of us use the word "grammar" to refer to the syntax in Annex A? A simple "yes" would be sufficient, even if you think we're wrong to use the word that way. [...] > Take this > > int x, y; > > y = x; > > The C compiler has to accept that. But of course it is incorrect, and most > compilers will warn about it. We could and often do declare warnings to > be errors, then it's "ungrammatical". No, a C compiler doesn't have to accept it. If that's the entire source file, it's invalid, since statements cannot appear at file scope. If it's inside a function definition, it has undefined behavior, and the compiler is permitted to terminate the translation with a diagnostic message. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */