When using ?const __int64? values these appear to be truncated to 32-bits?

Abstract: When using ?const __int64? values these appear to be truncated to 32-bits?

This is a code generation defect in the compiler?s handling of const __int64 values. It is best not to use ?const __int64? values (until the compiler is fixed), NOTE: normal __int64 values are handled correctly or it could be possible to use old style� #define values rather than "const __int64".

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

void __fastcall TForm4::Button1Click(TObject *Sender)
{
const __int64 BIGGEST = 0x7FFFFFFFFFFFFFFFLL;
__int64 dBIGGEST = 0x7FFFFFFFFFFFFFFFLL;
ShowMessage(IntToHex(BIGGEST,16) +" "+IntToHex(dBIGGEST,16));
}
>>>>>>>>>>>>>>>>>>>
3) build and run the app. the will show that BIGGEST is incorrect BUT dBIGGEST is correct?
it would appear as if the compiler is assuming that the const value is only 32-bits!

To corroborate this assumption one can change the above code to this:

>>>>>>>>>>>>>>>>>>>>>>>
void __fastcall TForm4::Button1Click(TObject *Sender)
{
const __int64 BIGGEST = 0x7FFFFFFFFFFFFFFFLL;
�� __int64 dBIGGEST = 0x7FFFFFFFFFFFFFFFLL;
�� __int64 Temp64 = *(__int64 *)(&BIGGEST);
�� ShowMessage(IntToHex(BIGGEST,16) +" "+IntToHex(Temp64,16) +" "+IntToHex(dBIGGEST,16));
}
>>>>>>>>>>>>>>>>>>>>>>>>
NOW
Temp64 is correct! BUT BIGGEST is still incorrect! even though BIGGEST was used to assign to Temp64, in a round about fashion!

Looking at this code
void __fastcall TForm4::Button1Click(TObject *Sender)
{
const __int64 BIGGEST = 0x7FFFFFFFFFFFFFFFLL;
__int64 dBIGGEST = 0x7FFFFFFFFFFFFFFFLL;
__int64 Temp64 = BIGGEST;
ShowMessage(IntToHex(Temp64,16) ;
}

When looking at the generated assembly code one can easily see the issue:
1) this is as expected
Unit4.cpp.21: const __int64 BIGGEST = 0x7FFFFFFFFFFFFFFFLL;
0040192A C745B8FFFFFFFF mov [ebp-$48],$ffffffff
00401931 C745BCFFFFFF7F mov [ebp-$44],$7fffffff
Unit4.cpp.22: __int64 dBIGGEST = 0x7FFFFFFFFFFFFFFFLL;
00401938 C745B0FFFFFFFF mov [ebp-$50],$ffffffff
0040193F C745B4FFFFFF7F mov [ebp-$4c],$7fffffff

2) BUT this shows the problem.
Unit4.cpp.26: __int64 Temp64 = BIGGEST;
00401946 C745B8FFFFFFFF mov [ebp-$48],$ffffffff
0040194D C745BCFFFFFFFF mov [ebp-$44],$ffffffff


Author: Roy Nelson