Talk:cpp/language/ub

Concerning the second point under "Explanation"
Violations of semantic rules that are not required to be diagnosed do not make a program ill-formed unless they violate the ODR. In other words, the only way to have a program that is ill-formed without requiring a diagnostic is either by violating syntactic rules for which no diagnostic is required (not sure if that's practicable) or by violating the ODR in a way that does not require a diagnostic.

Also, depending on interpretation, the fragment in parentheses may imply that all violations of the ODR are semantic errors not required to be diagnosed, which I do not believe is true.

Finally (and this may be nitpicking), for the last sentence, not only is behavior undefined for the execution of the program, but also for any sort of processing by the implementation (compiling/linking).

Ts137 (talk) 16:12, 30 June 2018 (PDT)
 * "the program is ill-formed; no diagnostic required" is standardese used to describe many language rules, one of which is ODR vioaltion. To name a few others: non-pure virtual function not defined, constructor delegates to itself, various template issues (some of which, I suppose, are sort of odr-like in spirit). Are you arguing that it isn't so? --Cubbi (talk) 06:25, 2 July 2018 (PDT)


 * No, you're right. Although I didn't find any mention of "ill-formed" in [basic.def.odr], I did find many instances of "ill-formed; no diagnostic required" elsewhere that seemed to refer to semantic violations having nothing to do with the ODR. I was going based on the definition of "ill-formed" in [intro.defs] ("program that is not well-formed"), which then, by the definition of "well-formed", suggests a "C++ program [not] constructed according to the syntax rules, diagnosable semantic rules, [or] the ODR." I felt this implied that a program with only semantic errors not required to be diagnosed would still be "well-formed", and thus not "ill-formed". Why else would the qualifier "diagnosable" be in the definition? --Ts137 (talk) 07:49, 2 July 2018 (PDT)


 * To be fair, "ill-formed NDR" is a strange beast that looks like a different way to spell "the behavior is undefined" except for some second-order differences: SO, SO, std-discussion (linked from that SO).. anything we could write other than repeating standardese would have to be justified by links to such commentary. --Cubbi (talk) 08:58, 2 July 2018 (PDT)


 * OK. I'm fine with the standardese. I think that the definition of "well-formed" in [intro.defs] is inconsistent with the use of its inverse ("ill-formed") throughout the standard where "no diagnostic is required", since, according to the latter, a program can be ill-formed NDR from semantic violations, yet, according to the former, also well-formed because those violations aren't necessarily diagnosable. Nevertheless, I suppose "ill-formed NDR" is far too widespread throughout the standard to justify a change to the UB page based on a single (and perhaps often overlooked) definition. I won't continue to beat this issue to death :) --Ts137 (talk) 10:03, 2 July 2018 (PDT)