GCC Hexadecimal Floating point constant handling

View: New views
2 Messages — Rating Filter:   Alert me  

GCC Hexadecimal Floating point constant handling

by Ameya Malondkar :: Rate this Message:

| View Threaded | Show Only this Message

GCC accepts constructs such as :  float p = 0x.p5;


As per C99 Standards the grammar for hexadecimal floating points is as follows :
hexadecimal-floating-constant:
                                        hexadecimal-prefix hexadecimal-fractional-constant
                                                             binary-exponent-part floating-suffix(opt)
                                        hexadecimal-prefix hexadecimal-digit-sequence
                                                             binary-exponent-part floating-suffix(opt)

hexadecimal-prefix: one of
                           0x 0X

hexadecimal-fractional-constant:
                                        hexadecimal-digit-sequence(opt) . hexadecimal-digit-sequence
                                        hexadecimal-digit-sequence .

binary-exponent-part:
                                        p signopt digit-sequence
                                        P signopt digit-sequence

hexadecimal-digit-sequence:
                                        hexadecimal-digit
                                        hexadecimal-digit-sequence hexadecimal-digit

floating-suffix: one of
                     f l F L


As per the grammar to my understanding, the above construct is invalid.
Just wanted to know whether the support for the above construct is a GCC Extension or my understanding of the grammar is incorrect?

Re: GCC Hexadecimal Floating point constant handling

by Ian Lance Taylor-3 :: Rate this Message:

| View Threaded | Show Only this Message

Ameya Malondkar <ameya.malondkar@...> writes:

> GCC accepts constructs such as :  float p = 0x.p5;

...

> As per the grammar to my understanding, the above construct is invalid.
> Just wanted to know whether the support for the above construct is a GCC
> Extension or my understanding of the grammar is incorrect?

I agree.  Per the grammar, this should not be recognized.

It does not real harm, but would you like to file a bug report?  See
http://gcc.gnu.org/bugs.html .  Thanks.

Ian