[Bug target/93934] Unnecessary fld of uninitialized float stack variable results in ub of valid C++ code
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 26 09:56:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93934
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-02-26
Ever confirmed|0 |1
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #5)
> Ah, indeed. fld won't raise FE_INVALID for 80-bit long double, but here
> 'result' is stored on the stack in 64-bit format.
>
> So: fcmov and 80-bit fldt don't trap, 32-bit flds and 64-bit fldl do.
>
> Somehow RTL if-conversion would have to check "-fsignaling-nans is requested
> and the target may raise FE_INVALID on loads" among other reason to reject a
> speculative load.
>
> I am afraid though that several other optimizations do not anticipate that
> x87 fp loads can raise exceptions on SNaNs either, making -fsignaling-nans
> difficult to implement in full.
I suppose a fldt followed by "truncation" to 32/64 bit would then trap at
the truncation step?
But yes, this will be difficult to handle. We'd have to mark all loads
from not must-initialized memory as possibly trapping and thus not eligible
for if-conversion. And this applies to possibly uninitialized registers
as well which might be spilled or allocated to the stack.
So confirmed at least. It's also more a middle-end issue affecting a
subset of targets only.
More information about the Gcc-bugs
mailing list