Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the rationale to "no diagnostic required"?

Most people are familiar with the "undefined" and "unspecified" behaviour notes in C++, but what about "no diagnostic required"?

I note this question and answer, dealing with ill formed programs, but not much detail on the root of "no diagnostic required" statements.

What is the general approach applied by the committee when classifying something as "no diagnostic required"?

  • How bad does the error need to be for the standards committee to specify it as such?
  • Are these errors of such a nature that it would be near impossible to detect, hence diagnose?

Examples of "undefined" and "unspecified" behaviour are not in short supply; short of the ODR, what practical example(s) are there for the "no diagnostic required" type errors?

like image 647
Niall Avatar asked Jul 22 '14 07:07

Niall


1 Answers

There was a discussion here: https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/lk1qAvCiviY with utterances by various committee members.

The general consensus appears to be

  • there is no normative difference
  • ill-formed; no diagnostic required is used only for compile-time rule violations, never for runtime rule violations.

As I said in that thread, I did once hear in a discussion (I can't remember anymore in which one, but I'm certain there were insightful committee members involved)

  • ill-formed; no diagnostic required for cases that clearly are bad rule violations and that can in principle be diagnosed at compile time, but would require huge efforts from an implementation.
  • undefined behavior for things that implementations could find useful meanings for, so don't neccessarily are pure evil, and for any runtime violations that results in arbitrary consequences.

The rough guide for me is; if it is at compile time, it tends to be "ill-formed; no diagnostic required" and if it is at runtime, it always is "undefined behavior".

like image 77
Johannes Schaub - litb Avatar answered Oct 12 '22 02:10

Johannes Schaub - litb