4 ms·
> In C99, it was made expressly legal, but it was erroneously included in the list of undefined behavior annex. In C99, union type punning was put under Annex
by trealira 1y ago
> In C99, it was made expressly legal, but it was erroneously included in the list of undefined behavior annex.
In C99, union type punning was put under Annex J.1, which is unspecified behavior, not undefined behavior. Unspecified behavior is basically implementation-defined behavior, except that the implementor is not required to document the behavior.
- ryao 1y agoWe can use UB to refer to both. :)
- trealira 1y agoMaybe, but we were talking about "undefined behavior," not "UB," so the point is moot.
- deleted 1y ago[deleted]
- hermitdev 1y ago> We can use UB to refer to both. :) You can, but in the context of the standard, you'd be wrong to do so. Undefined behavior and unspecified behavior have specific, different, meanings in context of the C and C++ standards. Conflate them at your own peril.
- JadeNB 1y ago> > We can use UB to refer to both. :) > You can, but in the context of the standard, you'd be wrong to do so. Undefined behavior and unspecified behavior have specific, different, meanings in context of the C and C++ standards. > Conflate them at your own peril. I think that ryao was not conflating them, but literally just pointing out, as a joke, that "UB" can stand for "undefined behavior" or "unspecified behavior." Taking advantage of this is inviting dangerous ambiguity, which is why ryao's suggestion ended with ":)," but I think that saying that it's wrong is an overstateent.