Bug 24976 - [4.8/4.9/5 Regression] simple hexadecimal number and plus/minus and no space
[4.8/4.9/5 Regression] simple hexadecimal number and plus/minus and no space
Status: NEW
Product: gcc
Classification: Unclassified
Component: preprocessor
4.0.3
: P5 minor
: 4.8.5
Assigned To: Not yet assigned to anyone
: diagnostic
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-21 17:24 UTC by Bernardo Innocenti
Modified: 2014-12-19 13:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3
Known to fail: 3.0.4, 4.0.4, 4.6.1, 4.6.3
Last reconfirmed: 2012-04-16 22:27:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernardo Innocenti 2005-11-21 17:24:19 UTC
This testcase:

  int a = 0xe+100;

Produces a diagnostic message that would surprise
most users:

 foo.c:1:9: error: invalid suffix "+100" on integer constant


I'm not sure what the standard says about ambiguity
between the hex float notation and the regular + operator,
but many users are going to think of this behavior as
a parser bug.
Comment 1 Andrew Pinski 2005-11-21 17:28:33 UTC
(In reply to comment #0)
> but many users are going to think of this behavior as
> a parser bug.

This is more of a tokenizer error rather than a parser error.

Anyways 2.95.3 gives:
t.c:1: missing white space after number `0xe'

I wonder if we should accept this code for -std=c89.
Comment 2 joseph@codesourcery.com 2005-11-21 18:21:48 UTC
Subject: Re:   New: simple hexadecimal number parsed as C99 hex
 float

On Mon, 21 Nov 2005, bernie at develer dot com wrote:

> This testcase:
> 
>   int a = 0xe+100;

0xe+100 is a single preprocessing number.  If the end of 
<http://gcc.gnu.org/onlinedocs/gcc/Incompatibilities.html> is unclear, 
please let us know how we could have improved it so that you would have 
realised it applies to this situation and so there is no bug.

Comment 3 Bernardo Innocenti 2005-11-21 18:41:15 UTC
(In reply to comment #2)

> 0xe+100 is a single preprocessing number.  If the end of 
> <http://gcc.gnu.org/onlinedocs/gcc/Incompatibilities.html> is unclear, 
> please let us know how we could have improved it so that you would have 
> realised it applies to this situation and so there is no bug.

We could handle it like we do for >> in nested template
declarations: split the token and try reparsing the
expression with the "other" meaning.  If it works, give
the friendly error message ("maybe you meant 0xe + 100?").
Comment 4 Andrew Pinski 2005-11-21 22:27:09 UTC
Confirmed, as a diagnostic issue only.  I am going to mark this as a regression even though I know that the preprocessor was rewritten between 2.95.3 and 3.0.x.
Comment 5 Mark Mitchell 2005-12-19 18:07:30 UTC
Downgraded to P5, as this will never be a release-critical issue.
Comment 6 Gabriel Dos Reis 2007-02-03 16:03:27 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 7 Joseph S. Myers 2008-07-04 20:14:33 UTC
Closing 4.1 branch.
Comment 8 Joseph S. Myers 2009-03-31 19:01:30 UTC
Closing 4.2 branch.
Comment 9 Richard Biener 2009-08-04 12:27:19 UTC
GCC 4.3.4 is being released, adjusting target milestone.
Comment 10 Richard Biener 2010-05-22 18:10:47 UTC
GCC 4.3.5 is being released, adjusting target milestone.
Comment 11 Richard Biener 2011-06-27 12:12:21 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 12 Jakub Jelinek 2012-03-13 12:45:09 UTC
4.4 branch is being closed, moving to 4.5.4 target.
Comment 13 Bernie Innocenti 2012-04-16 04:24:58 UTC
Confirmed on gcc 4.6.3.
Comment 14 Jakub Jelinek 2013-04-12 15:15:42 UTC
GCC 4.6.4 has been released and the branch has been closed.
Comment 15 Richard Biener 2014-06-12 13:41:50 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 16 Jakub Jelinek 2014-12-19 13:24:58 UTC
GCC 4.8.4 has been released.