<div dir="ltr">The test fails with -2^31 and 2^31-1<br>It&#39;s not so amazing, because when I debug, I find this incorrect version:<br><div><br>   64769    sqInt<br>   64770    signed32BitIntegerFor(sqInt integerValue)<br>   64771    {<br>-&gt; 64772        return (((((int) integerValue)) &lt;&lt; 3) | 1);<br>   64773    <br>   64774    }<br>   64775<br><br></div><div>of course, the shift will overflow for large positive or large negative 32bits int.<br></div><div>But I don&#39;t understand how it&#39;s been generated...<br></div><div>I would expect<br>    return ((((usqInt)((int) integerValue)) &lt;&lt; 3) | 1);</div><div><br>Indeed:<br><br>signed32BitIntegerFor: integerValue<br>    &quot;Answer a full 32 bit integer object for the given integer value.<br>     N.B.  Returning in each arm separately enables Slang inlining.<br>     /Don&#39;t/ return the ifTrue:ifFalse: unless Slang inlining of conditionals is fixed.&quot;<br>    &lt;inline: true&gt;<br>    objectMemory hasSixtyFourBitImmediates<br>        ifTrue:<br>            [^objectMemory integerObjectOf: <br>                (self cCode: [self cCoerceSimple: integerValue to: #int]<br>                    inSmalltalk: [(integerValue bitAnd: 16r7FFFFFFF)<br>                                - ((integerValue &gt;&gt; 31 anyMask: 1)<br>                                    ifTrue: [-16r100000000]<br>                                    ifFalse: [0])])]<br>        ifFalse:<br>            [^self noInlineSigned32BitIntegerFor: integerValue]<br><br></div><div>has the cast to int.<br></div><div>Then there is another cast here:<br><br>integerObjectOf: value<br>    &quot;Convert the integer value, assumed to be in SmallInteger range, into a tagged SmallInteger object.<br>     In C, use a shift and an add to set the tag bit.<br>     In Smalltalk we have to work harder because the simulator works with strictly positive bit patterns.&quot;<br>    &lt;returnTypeC: #sqInt&gt;<br>    ^self<br>        cCode: [value asUnsignedInteger &lt;&lt; self numTagBits + 1]<br>        inSmalltalk: [value &lt;&lt; self numTagBits<br>                    + (value &gt;= 0<br>                        ifTrue: [1]<br>                        ifFalse: [16r10000000000000001])]<br><br></div><div>and asUnsignedInteger is translated like this by CCodeGenerator:<br><br>generateAsUnsignedInteger: msgNode on: aStream indent: level<br>    &quot;Generate the C code for this message onto the given stream.&quot;<br><br>    aStream nextPutAll:&#39;((usqInt)&#39;.<br>    self emitCExpression: msgNode receiver on: aStream.<br>    aStream nextPut: $)<br></div><div><br></div><div>How the hell could the hardcoded (usqInt) be not generated?<br></div></div>