[Bug middle-end/69971] repetitive code with __builtin_return_address with a large level

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 28 19:53:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69971

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Yes, the warning does exist to warn about unsafe calls to the function (I added
it here: https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01702.html).  This bug
was meant to suggest a way to make the built-in safer by expanding it as a loop
rather than stream of repetitive load instructions, while also making the code
more space efficient.  But emitting a loop alone with no other checks (except
for the level) won't actually make the function safer.  The loop would also
have to validate the address at each iteration.  I'm not sure how easy,
efficient, or reliable this might be.  In the of a corrupted stack it certainly
wouldn't be reliable.


More information about the Gcc-bugs mailing list