Avoiding stack buffer clear being optimised out
Jonathan Wakely
jwakely.gcc@gmail.com
Tue Jan 24 14:26:24 GMT 2023
On Tue, 24 Jan 2023 at 13:52, Jonny Grant <jg@jguk.org> wrote:
>
> Probably other functions be "compiled out" like memset() is, would memcpy() be compiled out?
The compiler can do anything which does not change the observable side
effects of a valid program.
https://en.cppreference.com/w/cpp/language/as_if
So yes, the compiler can omit a memcpy that doesn't do anything. Or
any other function call that doesn't do anything.
More information about the Gcc-help
mailing list