I post a question in KDS: variable optimized out when compile with O2 and LTO option , and the last question is that:
as a sample followed:
when compiled with O2 and linked with LTO, the local varible addr will be optimized away even if the volatile added, maybe there has relation with the gcc's version.
I searched google, test some answer, and found no one satisfied.
thanks Jorge.
I have try it again just like this:
int volatile addr;
addr = (int)(&__SP_INIT);
The local addr optimized.
I'm not familay with assembly, so I have not try same as your's, which defined as a pointer. It will be no effect.
The differency should be the version of arm gcc, I'm using arm-none-eabi-gcc 4.9.2, I use it for a long time, there's maybe some risk changing other version of gcc, I doubt.
Which version of gcc you are using?
Hi
I'm using the KDS with default installation:
Release notes for
*************************************************
GNU Tools for ARM Embedded Processors 4.8
Best regards
Jorge Alcala