Bug 32782 - inconsistent overflow in implicit conversion warning with -sizeof()
Summary: inconsistent overflow in implicit conversion warning with -sizeof()
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-16 19:03 UTC by Steven L. Zook
Modified: 2008-03-30 22:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test code fragment compiled m68k-elf-g++ -c testpp.cpp (212 bytes, text/plain)
2007-07-16 19:05 UTC, Steven L. Zook
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven L. Zook 2007-07-16 19:03:32 UTC
When calling a procedure with signed char or short arguments using -sizeof() as an expression, an "<filename>:<line#>: warning: overflow in implicit constant conversion" is output. Arguments with int or long do not. This happens even though there is no real overflow (e.g. if -sizeof() evaluates to -4). See attached test program (compiled using command line m68k-elf-g++ -c testcpp.cpp). Proper code is produced. Warning can be avoided by casting sizeof() to int (i.e. -(int)sizeof() ). Similar results are obtained when returning a -sizeof() value in procedures with return type signed char or short. This warning does not occur in revision 3.4.6.
Comment 1 Steven L. Zook 2007-07-16 19:05:58 UTC
Created attachment 13926 [details]
Test code fragment compiled m68k-elf-g++ -c testpp.cpp

Lines end in \r\n.
Comment 2 Andrew Pinski 2007-07-16 19:30:01 UTC
The type of sizeof is unsigned. So you really have (short)(unsigned)-4 .
Comment 3 Andreas Schwab 2008-03-30 22:36:49 UTC
Not a bug.