News for hackers. Stuff that matters.
Re:The Lost Art of Structure Packing (2018) by gpderetta on Monday April 27, 2020 @03:05PM (#22998851)
It is complicated. Because of the as-if rule, a compiler can do anything it wants as long as a conforming program can't tell the difference. So for example if a compiler can prove that a program doesn't compare fiel addresses, doesn't cast pointer to a struct to its first member, etc it can reorder as it pleases. Turns out it is very hard to prove, often requires whole program optimization and the gains are questionable, so it is seldom done. Both clang and gcc had such an optimization pass in the past but it got dropped.

There are no comments on this comment yet.