This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Incorrect code generation ACOMPE 6.21 with -O1

In a little piece of test code, I have the following:

Very simple.

When compiling with -O0, the disassembly for the relevant part looks like:

But with -O1 or higher optimization:

All of a sudden, the comparison after the call to osKernelInitialize is gone...

The while(true) is only there temporarily, and I am aware that it can be optimized away as it undefined behavior, but I do expect the compiler to actually handle the preceding if-statement properly first.

0