hex float constants broken

Stephen L Moshier moshier@mediaone.net
Fri Oct 29 17:09:00 GMT 1999


Here are test case, symptoms, and fix.


double x = 0x1.fp1;
int main()
{
  if (x !=  3.875)
    abort ();
  exit (0);
}

p5.c:1: hexadecimal floating constant has no exponent
p5.c:1: missing white space after number `0x1.'
p5.c:1: parse error before `p1'

	* c-lex.c (yylex): Accept 'f' in mantissa of hex float constant.

*** c-lex.c	1999/10/29 16:03:07	1.2
--- c-lex.c	1999/10/29 23:51:19
*************** yylex ()
*** 1481,1487 ****
  	       || (ISALNUM (c) && c != 'l' && c != 'L'
  		   && c != 'u' && c != 'U'
  		   && c != 'i' && c != 'I' && c != 'j' && c != 'J'
! 		   && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
  	  {
  	    if (c == '.')
  	      {
--- 1481,1489 ----
  	       || (ISALNUM (c) && c != 'l' && c != 'L'
  		   && c != 'u' && c != 'U'
  		   && c != 'i' && c != 'I' && c != 'j' && c != 'J'
! 		   && (floatflag == NOT_FLOAT
! 		       || ((base != 16) && (c != 'f') && (c != 'F'))
! 		       || base == 16)))   
  	  {
  	    if (c == '.')
  	      {



More information about the Gcc-bugs mailing list