|
|
Subscribe / Log in / New account

Undefined Behaviour as usual

Undefined Behaviour as usual

Posted Mar 25, 2024 9:17 UTC (Mon) by farnz (subscriber, #17727)
In reply to: Undefined Behaviour as usual by Cyberax
Parent article: Stenberg: DISPUTED, not REJECTED

It's UB in Standard C; POSIX defines it the way you state, but Standard C intends to support Harvard Architecture systems where void * is not large enough to store a function pointer.

This relates to one of the less annoying misconceptions about UB; while the ISO Standard may leave something as UB, or explicitly state that it's UB, it is perfectly permissible for downstream standards and implementations to define something that's UB in Standard C. So, for example, instead of getting Standard C to fix the shifting behaviour, we could (at least in theory) have made it a POSIX obligation on both C and C++ compilers, and required compilers to either drop POSIX support or do the sensible shift behaviour defined in C++20.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds