On 14/11/17 19:36, Jorge Almeida wrote:
On Fri, Nov 10, 2017 at 12:09 PM, Jorge Almeida <jjalme...@gmail.com> wrote:

http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html


Of course, what would really solve the optimize-into-oblivion problem
is a pragma that when invoked on a particular block of code (maybe
only a function definition) would tell the compiler to do what the
programmer says rather than viewing a function as a kind of black box.



It seems a solution exists with gcc:

https://stackoverflow.com/questions/2219829/how-to-prevent-gcc-optimizing-some-statements-in-c

The last reply:

void __attribute__((optimize("O0"))) foo(unsigned char data) {
     // unmodifiable compiler code
}

Any comments, anyone?
Unless you look at the assembly output, you can't be sure. Some optimization is done even at -O0.

I'd stick to using explicit_bzero() which is safe regardless of compiler vendor *and* version.


Reply via email to