3 ms·
C guarantees some properties. The platform ABI is guaranteed to work in a certain way. In this specific case, the compiler is not allowed to make any assumpti
by _pmf_ 10y ago
C guarantees some properties.
The platform ABI is guaranteed to work in a certain way.
In this specific case, the compiler is not allowed to make any assumptions about the legality, but has to follow the ABI.
There's no UB involved (not every platform specific issue may be labeled UB; think accessing bare metal memory on one platform where a specific address is IO mapped and on another it is regular SRAM; it's perfectly valid C, and has perfectly known semantics on both platforms, but will work on one platform and not work on another platform; this is also not UB).
- yoklov 10y agoNope, it's UB[0]. While not everything that doesn't work on every platform is UB, plenty of things are. Consider signed integer overflow, which is a common source of UB. To be clear, UB means the compiler is allowed to e.g. totally remove the call (or really anything else it wants to do at all) if it can be positive that this is what's happening -- not that it will behave as could be expected on the platform, the term for that would be implementation defined behavior. [0]: http://c0x.coding-guidelines.com/6.3.2.3.html http://c0x.coding-guidelines.com/6.3.2.3.html number 766-768
- _pmf_ 10y agoYou're right.