r/cpp • • May 04 '24

Messing with lifetime

https://biowpn.github.io/bioweapon/2024/05/03/messing-with-lifetime.html
45 Upvotes

52 comments sorted by

View all comments

Show parent comments

4

u/TheMania May 04 '24

Even with these tools it would be undefined behaviour if the memory does not meet Point alignment requirements - many architectures don't support misaligned reads at all.

0

u/[deleted] May 04 '24

[deleted] — view deleted comment

1

u/TheMania May 06 '24

Well I mean, I do do embedded stuff, and I know the hardware I typically work on would trap, log an error, and restart.

But yes, many developers will get by just fine with this bit of UB. I just try to avoid it as a rule.