Bug 506495 - error vs warning for "integer constant is too large for ‘long’ type"
error vs warning for "integer constant is too large for ‘long’ type"
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc (Show other bugs)
5.4
ppc Linux
low Severity low
: rc
: ---
Assigned To: Jakub Jelinek
BaseOS QE
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-17 10:41 EDT by Michal Nowak
Modified: 2013-03-07 21:06 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-06-17 10:48:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michal Nowak 2009-06-17 10:41:49 EDT
Description of problem:

g++ fails where g++44 warns:

/usr/bin/g++ -Ibuild/include -O0  -D_REENTRANT -ansi -Wno-long-long -W -Wall -fPIC -c src/block/des/des_tab.cpp -o build/lib/des_tab.o
src/block/des/des_tab.cpp:373: error: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:373: error: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:374: error: integer constant is too large for ‘long’ type
[...]
src/block/des/des_tab.cpp:634: error: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:634: error: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:634: error: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:634: error: integer constant is too large for ‘long’ type

g++44:

/usr/bin/g++44 -Ibuild/include -O0  -D_REENTRANT -ansi -Wno-long-long -W -Wall -fPIC -c src/block/des/des_tab.cpp -o build/lib/des_tab.o
src/block/des/des_tab.cpp:373: warning: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:373: warning: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:374: warning: integer constant is too large for ‘long’ type
src/block/des/des_tab.cpp:374: warning: integer constant is too large for ‘long’ type


The code is:

const u64bit DES_IPTAB1[256] = {
0x0000000000000000, 0x0000000200000000, 0x0000000000000002, 0x0000000200000002,
0x0000020000000000, 0x0000020200000000, 0x0000020000000002, 0x0000020200000002,
0x0000000000000200, 0x0000000200000200, 0x0000000000000202, 0x0000000200000202,
[...]

Version-Release number of selected component (if applicable):

gcc-4.1.2-46.el5

Additional info:

Wonder why it behaves differently on g++ and g++44. I guess the code is not 100 % valid but can it be enhanced in some way?
Comment 1 Jakub Jelinek 2009-06-17 10:48:31 EDT
Some diagnostic has been recategorized from warning to error or vice versa, some diagnostics are errors only with -pedantic now, etc.
That is not a bug.
If you want to avoid the warnings/errors, just add LL suffix to the constants.

Note You need to log in before you can comment on or make changes to this bug.