Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: I think references should have been const by default Date: Mon, 25 Oct 2021 11:11:47 -0700 Organization: None to speak of Lines: 51 Message-ID: <8735op2cv0.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="ce9c6a8e39b023180b9e14b2203de6ab"; logging-data="1558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3yuuSnbLmP4rZ/006xD7i" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:T1I68Y1zai2IBAXGxNfVAU3cC6U= sha1:G8Hjw50It3C5kt9x5WDzYN/bpfQ= Xref: csiph.com comp.lang.c++:82082 Manfred writes: > On 10/25/2021 4:59 PM, James Kuyper wrote: >> On 10/25/21 10:19 AM, RacingRabbit@watershipdown.co.uk wrote: > >>> >>> No idea what UB means, but what'll happen is it'll crash immediately so you'll >>> soon find out. >> UB means "Undefined Behavior", a technical term from the C standard >> which does NOT mean "behavior for which there is no definition". It >> means "behavior, upon use of a nonportable or erroneous program >> construct or of erroneous data, for which this document imposes no >> requirements" (3.4.3). Note that "this document" refers to the C >> standard; other documents (such as compiler documentation or ABI >> standards) might define the behavior, without changing the fact that is >> qualifies as "undefined behavior" as far as the C standard is concerned. > > Thanks for the quote, it made me compare it with the definition of UB > in the C++ standard, which simply states "behavior for which this > International Standard imposes no requirements". > > The lack of the sentence "upon use of a nonportable or erroneous > program construct or of erroneous data" actually relegates the > language at the mercy of language lawyers, and led to the UB bloat > that affects C++ nowadays. [...] I don't see how the omission of "upon use of a nonportable or erroneous program construct or of erroneous data" in the C++ standard makes any real difference. C definition, all standard editions: behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements C++ definition, before C++11: behavior, such as might arise upon use of an erroneous program construct or erroneous data, for which this International Standard imposes no requirement C++ definition, C++11 and later: behavior for which this International Standard imposes no requirements In all cases, "undefined behavior" is determined either by an explicit statement or by the omission of any definition of the behavior (or, in C, by violation of a "shall" outside a constraint). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */