Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/C++/Front End/Diagnostics    [ Add a report in this area ]  
Report #:  47944   Status: Open
Bad warning on casted long long (__int64)
Project:  C++Builder Build #:  11.0.2709.7126
Version:    11.0 Submitted By:   Endre Simay
Report Type:  Minor failure / Design problem Date Reported:  6/22/2007 7:03:54 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   251661
Resolution: Need More Info (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
The lines like:
__int64 mymin = __int64(9223372036854775807);
__int64 mymin = (__int64)9223372036854775807;  
__int64 mymin = (long long)9223372036854775807;

result a warning about integer overflow.
Steps to Reproduce:
insert any of the lines :
__int64 mymin = __int64(9223372036854775807);
__int64 mymin = (__int64)9223372036854775807;  
__int64 mymin = (long long)9223372036854775807;

press ctrl+F9.

result a warning about potential overflow, while this warning probably not needed. Just because  9223372036854775807 is a valid value for __int64, and the cast probably could avoid the overflow, too.
Workarounds
None
Attachment
None
Comments

Alisdair Meredith at 9/2/2010 6:28:01 AM -
The warning look correct as the literals are 'int' literals.  If you want to parse as 64-bit literals, you need to make them 'long long' literals with the LL suffix.

Tomohiro Takahashi at 9/2/2010 10:10:44 PM -
Thanks for the information, Alisdair-san.

Server Response from: ETNACODE01