GCC Bugzilla – Bug 24976
[4.8/4.9/5 Regression] simple hexadecimal number and plus/minus and no space
Last modified: 2014-12-19 13:24:58 UTC
int a = 0xe+100;
Produces a diagnostic message that would surprise
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.
(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.
Subject: Re: New: simple hexadecimal number parsed as C99 hex
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.
(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?").
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.
Downgraded to P5, as this will never be a release-critical issue.
Won't fix in GCC-4.0.x. Adjusting milestone.
Closing 4.1 branch.
Closing 4.2 branch.
GCC 4.3.4 is being released, adjusting target milestone.
GCC 4.3.5 is being released, adjusting target milestone.
4.3 branch is being closed, moving to 4.4.7 target.
4.4 branch is being closed, moving to 4.5.4 target.
Confirmed on gcc 4.6.3.
GCC 4.6.4 has been released and the branch has been closed.
The 4.7 branch is being closed, moving target milestone to 4.8.4.
GCC 4.8.4 has been released.