Bug 39559 - constants too large for intmax_t need pedwarns
Summary: constants too large for intmax_t need pedwarns
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2009-03-26 01:33 UTC by Joseph S. Myers
Modified: 2009-04-25 18:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.0
Known to fail:
Last reconfirmed: 2009-03-30 00:44:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2009-03-26 01:33:23 UTC
unsigned long long l = 9223372036854775808LL;

should get an error with -std=c99 -pedantic-errors, but instead gets a warning:

t.c:1:24: warning: integer constant is so large that it is unsigned

C99 does not allow decimal constants without "U" suffix to get an
unsigned type.  I think the preprocessor should pedwarn in this case
(for C99, not C90), to catch the use of such constants in
#if conditions as well.

The preprocessor already pedwarns for a value large enough to be outside
the range of uintmax_t (which is used to set the preprocessor's
internal precision), so I believe this case of a constant inside the range
of uintmax_t but outside that of intmax_t, in decimal without "U" suffix,
is the only current case of this bug.

See <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38934#c15> for some
historical discussion (but it doesn't appear types wider than intmax_t
can ever appear this way after all).
Comment 1 Joseph S. Myers 2009-04-25 18:46:22 UTC
Subject: Bug 39559

Author: jsm28
Date: Sat Apr 25 18:46:03 2009
New Revision: 146777

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146777
Log:
libcpp:
	PR preprocessor/39559
	* expr.c (cpp_interpret_integer): Use a pedwarn for decimal
	constants larger than intmax_t in C99 mode.

gcc/testsuite:
	* gcc.dg/c99-intconst-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/c99-intconst-2.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/expr.c

Comment 2 Joseph S. Myers 2009-04-25 18:52:09 UTC
Fixed for 4.5.