https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94747
Nathan Sidwell <nathan at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-04-24 Summary|Undefined behavior: integer |Confusing code in |overflow in |libsupc++/dyncast.cc |libsupc++/dyncast.cc | CC| |nathan at gcc dot gnu.org Status|RESOLVED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |nathan at gcc dot gnu.org Resolution|INVALID |--- Ever confirmed|0 |1 --- Comment #3 from Nathan Sidwell <nathan at gcc dot gnu.org> --- While the code is well formed, it does not convey intent well. I wrote that code, and probably even considered spelling as -ptrdiff_t (offsetof ...). but didn't because it causes a line wrap and has no semantic difference. negating unsigned numbers often shows programmer confusion, and can cause bugs on I32LP64 systems, where the negation happens at a lower precision than expected. That's not the case here. If size_t has fewer bits than a pointer, there cannot be overflow from the top size_t bit to the pointer arithmetic -- that breaks C & C++ semantics. Something for stage 1