4 ms·
What I don't understand is why it doesn't optimize away the check on (inode->i_nlink), since it is assuming the code in the dependent block always runs. It has
by ncmncm 8y ago
What I don't understand is why it doesn't optimize away the check on (inode->i_nlink), since it is assuming the code in the dependent block always runs.
It has to be assuming that, because it is the only path that doesn't lead to undefined behavior.
- firethief 8y agoThe optimizer isn't required to eliminate code paths encountering dynamic UB; it is allowed to. It also doesn't have to be consistent in its "assumptions", although inconsistency may be a sign of missing efficiency somewhere
- metaphor 8y ago> The optimizer isn't required to eliminate code paths encountering dynamic UB; it is allowed to. If I understood correctly, Linus had some colorful thoughts[1] on that: If you know something is undefined, you warn about it. You don't silently generate random code that doesn't match the source code just because some paper standard says you "can". [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89501#c12 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89501#c12