Optimizations in Constructors?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I recently encountered a problem with a function was marked as a
constructor. The source file was compiled with -O0, but it appears the
function was optimized to the point it skipped some of the startup
code and jumped into the failure state (which called exit). I was able
to restore desired behavior with '#pragma GCC optimize("O0")' around
the function (even volatile tricks did not help).

The startup code had to do with an integrity check. The expected
fingerprint was back-patched after compiling, and then recalculated at
runtime. Then, a memcmp was made. It appears the compiler deduced that
the allocation was a string of 0's and could never be equal to the
runtime fingerprint, so its just omitted the code.

Is this expected behavior for functions marked as constructors
(compiled with -O0)?

Jeff




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux