Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 4
    $\begingroup$ Ah, I thought I had read this answer already elsewhere $\endgroup$ Commented Aug 18, 2023 at 10:10
  • 3
    $\begingroup$ Note that languages can also have implementation-defined behavior. That allows the defined behavior to depend on the hardware, so that it is two's compliment on machines that have it and sign-bit for the others; reducing the overhead in point 3 - but making the language less portable. (Sort of making a language dialect for each implementation.) $\endgroup$ Commented Aug 18, 2023 at 11:02
  • 1
    $\begingroup$ @Bergi Yes, it was a similar, but distinct, question. $\endgroup$ Commented Aug 18, 2023 at 11:05
  • 1
    $\begingroup$ @HansOlsson Yes. I think that a lot of C programmers which predate C99 have (or, at least, had) a mental model that "undefined behaviour" means "implementation-defined behaviour". Compiler developers have changed that in recent decades; it now unofficially means "benchmark-exploitable behaviour". $\endgroup$ Commented Aug 18, 2023 at 11:09
  • 4
    $\begingroup$ I'm not sure there's really much difference between the two definitions of UB. The inclusion of "unpredictable results" in the first version makes any result possible, so there's little difference between "possible" and "permissible". The rewording was presumably made for clarity, not to impose any different requirements. $\endgroup$ Commented Aug 18, 2023 at 14:18