<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Okay. Then Sema should insert an ImplicitCastExpr, just like it does for x1 and x2.<div><br><div><div>On Nov 13, 2008, at 8:24 PM, Zhongxing Xu wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; "><div bgcolor="#FFFFFF"><div><br class="Apple-interchange-newline">I'm not certain. Note that the 'long long' value 'k' was not truncated. Is this a Sema bug, or is this the correct behavior? For this target LongLongWidth is 64, the bit width for 'int' is 32, and the bit width for a pointer is (I believe) 32 bits as well.</div></div></blockquote></div><br>It's truncated in the generated code:<br><br>void f() {<br> int a[10];<br> short x1;<br> unsigned short x2;<br> long x5;<br> unsigned long x6;<br> long long x3;<br> unsigned long long x4;<br> <span class="Apple-converted-space"> </span><br> a[x1] = 3;<br> a[x2] = 3;<br> a[x3] = 3;<br> a[x4] = 3;<br> a[x5] = 3;<br> a[x6] = 3;<br>}<br><br>; ModuleID = 'array3.c'<br>target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"<br>target triple = "i686-pc-linux-gnu"<br><br>define void @f(...) nounwind {<br>entry:<br> %a = alloca [10 x i32], align 4 ; <[10 x i32]*> [#uses=6]<br> %x1 = alloca i16, align 2 ; <i16*> [#uses=1]<br> %x2 = alloca i16, align 2 ; <i16*> [#uses=1]<br> %x5 = alloca i32, align 4 ; <i32*> [#uses=1]<br> %x6 = alloca i32, align 4 ; <i32*> [#uses=1]<br> %x3 = alloca i64, align 4 ; <i64*> [#uses=1]<br> %x4 = alloca i64, align 4 ; <i64*> [#uses=1]<br> %tmp = load i16* %x1 ; <i16> [#uses=1]<br> %arraydecay = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> %idxprom =<span class="Apple-converted-space"> </span><b>sext<span class="Apple-converted-space"> </span></b>i16 %tmp to i32 ; <i32> [#uses=1]<br> %arrayidx = getelementptr i32* %arraydecay, i32 %idxprom ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx<br> %tmp1 = load i16* %x2 ; <i16> [#uses=1]<br> %arraydecay2 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> %idxprom3 =<span class="Apple-converted-space"> </span><b>zext</b><span class="Apple-converted-space"> </span>i16 %tmp1 to i32 ; <i32> [#uses=1]<br> %arrayidx4 = getelementptr i32* %arraydecay2, i32 %idxprom3 ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx4<br> %tmp5 = load i64* %x3 ; <i64> [#uses=1]<br> %arraydecay6 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> <span class="Apple-converted-space"> </span><b>%idxprom7 = trunc i64 %tmp5 to i32 ; <i32> [#uses=1]</b><br> %arrayidx8 = getelementptr i32* %arraydecay6, i32 %idxprom7 ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx8<br> %tmp9 = load i64* %x4 ; <i64> [#uses=1]<br> %arraydecay10 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> <span class="Apple-converted-space"> </span><b>%idxprom11 = trunc i64 %tmp9 to i32 ; <i32> [#uses=1]</b><br> %arrayidx12 = getelementptr i32* %arraydecay10, i32 %idxprom11 ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx12<br> %tmp13 = load i32* %x5 ; <i32> [#uses=1]<br> %arraydecay14 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> %arrayidx15 = getelementptr i32* %arraydecay14, i32 %tmp13 ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx15<br> %tmp16 = load i32* %x6 ; <i32> [#uses=1]<br> %arraydecay17 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]<br> %arrayidx18 = getelementptr i32* %arraydecay17, i32 %tmp16 ; <i32*> [#uses=1]<br> store i32 3, i32* %arrayidx18<br> br label %return<br><br>return: ; preds = %entry<br> ret void<br>}</span></blockquote></div><br></div></body></html>