[cfe-dev] Strict overflow warning

Richtarsky, Martin martin.richtarsky at sap.com
Fri Sep 21 03:19:06 PDT 2012

Hi Martin,

I don't think there is such warning in clang, but you could use the -fwrapv option to define signed integer arithmetic to wrap around on overflow -- this is the easy option.  You could also use the -fcatch-undefined-behavior option to catch signed overflow at runtime and turn it into a crash so that you can debug and fix it.


Hi Dimitri,

yes, -fwrapv or -fno-strict-overflow could be used here. But I would like to see which places are affected, so it would be great if -Wstrict-overflow would work. The option also seems to be recognized by the driver otherwise there would be a warning. It just does not seem to work internally which is bad if you rely on it (e.g. porting a GCC codebase).

Best regards,

More information about the cfe-dev mailing list