3 ms·
I do not see there a promise that the cast will produce an invalid pointer, nor anything prohibiting the compiler from rounding the pointer down, thus producing
by dmitrygr 5mo ago
I do not see there a promise that the cast will produce an invalid pointer, nor anything prohibiting the compiler from rounding the pointer down, thus producing a valid one. “Converted” does not require bit copy. I don’t see how this interpretation is against any section of the spec.
- cyclopeanutopia 5mo ago> Otherwise, when converted back again, the result shall compare equal to the original pointer. Doesn't this part exclude the possibility of rounding down?
- dmitrygr 5mo agoNo cause that requires initial alignment.
- deleted 5mo ago[deleted]
- dwattttt 5mo agoI also do not see any requirement in the quoted text that the casted pointer be dereferenced before noting "the behavior is undefined". In practice performing a cast doesn't really do much until you dereference, but without a carve out in the spec, it does really mean "the behavior is undefined".
- pjc50 5mo ago> rounding the pointer down, thus producing a valid one A "valid" pointer to the wrong object?
- dmitrygr 5mo agoWhich is ok since it is UB to deref