gcc optimization? bug? and its practial implication to project

前端 未结 5 1421
谎友^
谎友^ 2021-01-11 16:11

My questions are divided into three parts

Question 1
Consider the below code,

#include 
using namespace std;

i         


        
5条回答
  •  情话喂你
    2021-01-11 16:48

    It's a known problem, and I don't think it's considered a bug in the compiler. When I compile with gcc 4.5 with -Wall -O2 it warns

    warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false

    Although your code does overflow.

    You can pass the -fno-strict-overflow flag to turn that particular optimization off.

提交回复
热议问题