public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc not recognizing all C99 hex float constants
@ 2003-03-13 20:22 Michael Matz
  2003-03-13 20:49 ` Neil Booth
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Matz @ 2003-03-13 20:22 UTC (permalink / raw)
  To: gcc

Hi,

I noticed, that even in C99 mode gcc doesn't recognize all hexadecimal
floating point constants.

Compile this with "gcc -std=c99":

  float f = 0x.9p0;

this gives the error
  ppnumber.c:1:11: invalid suffix "x.9p0" on integer constant

This is because cppexp.c:cpp_classify_number() only wants to go to base 16
(after it sees "0x"), if the following char is a hex digit (i.e. it
doesn't like the '.').

6.4.4.2 explicitely mentions, that for a 'hexadecimal-fractional-constant'
the initial 'hexadecimal-digit-sequence' before '.' is optional.


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gcc not recognizing all C99 hex float constants
  2003-03-13 20:22 gcc not recognizing all C99 hex float constants Michael Matz
@ 2003-03-13 20:49 ` Neil Booth
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Booth @ 2003-03-13 20:49 UTC (permalink / raw)
  To: Michael Matz; +Cc: gcc

Michael Matz wrote:-

> Hi,
> 
> I noticed, that even in C99 mode gcc doesn't recognize all hexadecimal
> floating point constants.
> 
> Compile this with "gcc -std=c99":
> 
>   float f = 0x.9p0;
> 
> this gives the error
>   ppnumber.c:1:11: invalid suffix "x.9p0" on integer constant
> 
> This is because cppexp.c:cpp_classify_number() only wants to go to base 16
> (after it sees "0x"), if the following char is a hex digit (i.e. it
> doesn't like the '.').

Well spotted.
 
> 6.4.4.2 explicitely mentions, that for a 'hexadecimal-fractional-constant'
> the initial 'hexadecimal-digit-sequence' before '.' is optional.

Could you do the obvious patch (+ testcase)?  I can do it, but you'll
have to wait a few days.

Neil.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-13 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 20:22 gcc not recognizing all C99 hex float constants Michael Matz
2003-03-13 20:49 ` Neil Booth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).