Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22057

if one liner O3 optimization behavior issue [closed]

$
0
0

My code looks like this

int condition = 0;
// some code makes condition might not be 0
bool flag = condition ? 1:0;

In GCC debug mode (-O0), flag value is either 1 or 0 as expected. However, in GCC release with debug info mode (-O2 -g), I found in some cases flag value is same as condition value, say 50. Not 1 as expected.

I wonder why is that?


Viewing all articles
Browse latest Browse all 22057

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>