C23 reference links
C23 reference links
Posted Jul 24, 2024 12:05 UTC (Wed) by excors (subscriber, #95769)In reply to: C23 reference links by Karellen
Parent article: GNU C Library 2.40 released
C17 tightened the definition, but badly - the wording was internally inconsistent, and also incompatible with glibc, probably unintentionally. (https://sourceware.org/legacy-ml/libc-alpha/2019-08/msg00...)
(C17 also said "Invoking realloc with a size argument equal to zero is an obsolescent feature", which means it "may be considered for withdrawal in future revisions of this International Standard", so there's been plenty of warning.)
My guess is that the standards people realised it was really hard to come up with a precise definition that was self-consistent, useful, and compatible with reality, and it's not a good use of their time to keep discussing it when it's such a pointless feature anyway (just call free(ptr) if that's what you want), so they gave up and called it undefined. Platforms and compilers can still document the behaviour they actually implement, so nothing will really change.
Posted Jul 24, 2024 15:53 UTC (Wed)
by khim (subscriber, #9252)
[Link]
Seriously? I have a newsflash for you: any practical programmer would attest that even extra-vague “anything but UB” definition is still better than UB. Because “anything but UB” behavior should be predictable and debuggable. It may not be what you want or need, but it's not “your program works for years, then stops working because starts aligned differently” that UB signifies!
> It used to be unspecified behaviour (meaning the standard "provides two or more possibilities and imposes no further requirements on which is chosen in any instance"), and I think the basic problem was that the standard was so vague as to be practically useless.
C23 reference links
