[cfe-dev] constant propagation produces undef

Chris Lattner clattner at apple.com
Fri Jan 22 10:10:44 PST 2010

On Jan 22, 2010, at 9:24 AM, Alireza.Moshtaghi at microchip.com wrote:

> For us all undefined values are zero, I tried it on ARM and X86 also  
> and
> clang generates zero, and not an undefined.

That is because on x86 and arm, int -> i32.  This produces undef on x86:

int test() {
int x = 1;
return x << 32;

> Maybe the better question would be "how can I tell clang to replace  
> all
> undefined values with zero constant?"

You can't, that's not how C works.  If you build with the -fcatch- 
undefined-behavior option, it should catch this error at runtime.


More information about the cfe-dev mailing list