Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: UB in asm Date: Tue, 26 Dec 2017 12:44:51 -0800 Organization: None to speak of Lines: 33 Message-ID: References: <3c2ca45f-f33f-45ca-9f64-abf82f246588@googlegroups.com> <1TV%B.77911$q_1.6982@fx16.am4> <87h8sd8iz1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="203d090143056b2d39d58191552d6d39"; logging-data="22106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190sQYYag6X8ttflviDpfLt" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:tIpDUkvuCmObmTmrOhoa1ix0Y04= sha1:78Dd09ytWk59KEZNc1XnsAXaf78= Xref: csiph.com comp.lang.c:124718 supercat@casperkitty.com writes: [...] > Setting aside the "One Program Rule" loophole, a conforming implementation > must correctly process programs that could invoke UB with some inputs, in > cases where the actual inputs receive do not invoke UB. > > On the other hand, a conforming implementation is allowed to output any > diagnostics it likes when given any source text, provided that it then > proceeds to process such text in accordance with the Standard. > > Consequently, I think the -pedantic-errors flag puts gcc into a non-conforming > mode. > > I think, however, that even without such flags there are some cases where gcc > regards as fatal certain pieces of code which should only generate UB if > executed (such as assignments which involve incomplete structure types). I > suspect that such constructs were classified as UB rather than constraint > violations to allow for the possibility of compilers which could handle > such assignments, as well as the possible existence of code that might rely > upon them. Such code would not be portable to other platforms, but there > was no reason that compilers which could accept it should not be allowed > to keep doing so. Are you referring to 6.3.2.1p2, "If the lvalue has an incomplete type and does not have array type, the behavior is undefined."? If so, I'm having difficulty coming up with an example that could have meaningful semantics. Do you have one? -- 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"