22:30
A lot of software, including most software that runs on embedded platforms, is written in a form of high-level assembly language invented by Dennis Ritchie, which many compilers can be configured to process, at least with optimizations disabled, which augments the Standard with "Any parts of the Standard which would characterize an action as invoking UB are subservient to parts of the Standard, K&R2, and the documentation for the implementation and execution environment...
...which would otherwise specify the behavior". Many implementations, even with optimizations disabled, may in some corner cases slightly deviate from the behaivors that might be implied by that rule, but a prerequisite for allowing programs to work by specification is recognizing the existence of a dialect which specifies many actions' behavior as "Instruct the execution environment to do X, with whatever consequences result", without regard...
...to whether or how the execution environment specifies the consequences of the behavior. If a Commodore 64 is used to run code generated by a low-level C implementation targeting the 6502 and given (char volatile*)0xD020 = 7;
, the screen border should turn yellow, regardless of whether the author of the C implementation knows anything about Commodore 64, screens, borders, or the color yellow, because the Commodore 64 hardware has a 4-bit latch which is triggered by writes to 0xD020, and...
...the output from that latch will be fed to a color-generation circuit when raster scanning is within neither the main displayable area nor a blanking interval.
Writing a langauge spec that would satisfy the needs of the extremely vast majority of code written for freestanding implementations (nearly all such code that doesn't use nonstandard toolset-specific syntax) would not be difficult. Recognize the notion of a platform ABI that defines a few operations, and then specify that a translator's job is to convert each function into some kind of build artifact such that an execution environment that satisfies all of a compiler's documented requirements
...would have no choice but to behave in a manner whose observable behavior as defined by the platform ABI would be consistent with performing the indicated sequence of steps. Note that in most cases, platform ABIs would give compilers a lot of flexibility with regard to how they process things, thus allowing efficient C code to be translated into efficient machine code.
A fundamental difference between the FORTRAN abstraction model and Dennis Ritchie's abstraction model is that in the FORTRAN abstraction model, a compiler is entitled to assume that programmers won't exploit any knowledge about programmers' inner workings beyond what the Standard would provide, while C was designed around the assumption that programmers would often know things about the execution environment that a compiler likely wouldn't know and in many cases couldn't know.
@AlexisKing The issues raised by such defect reports would evaporate if the Commitee would recognize that if for 90% of tasksthe most efficient way of accomplishing what needs to be done wouldn't involve doing X, allowing compilers to assume that programs won't do X might improve the performance of 90% of tasks, but woudl be at best counterproductive for the remaining 10%.
For the extremely vast majority of programs and potential optimizations the Standard tries to use tricky rules to allow, it would be easy to identify at least one of the following as being true: (1) the optimization could be applied broadly without adversely affecting the program, or (2) performance objectives could be satisfied without trying to apply that particular optimization at all. Specifying a means by which programmers can say which situation applies would make it easier...
...for compilers to reap maximum benefits from programs that can benefit from the optimizations, while at the same time making it easier for programmers to write code that works by specification, rather than as a consequence of "missed optimizations".