[cfe-dev] constant propagation produces undef

Alireza.Moshtaghi at microchip.com Alireza.Moshtaghi at microchip.com
Fri Jan 22 20:57:20 PST 2010

I fixed it in the backend.


-----Original Message-----
From: Chris Lattner [mailto:clattner at apple.com] 
Sent: Friday, January 22, 2010 11:11 AM
To: Alireza Moshtaghi - C13012
Cc: eli.friedman at gmail.com; cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] constant propagation produces undef

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