This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Committed] PR19983: Support __builtin_nan("0X1")


The following patch resolves PR middle-end/19983, by allowing both
"0X" and "0x" as hexadecimal prefixes in real_nan, used to evaluate
the GCC builtin for C99's nan* functions at compile-time.  Most
would call the patch below obvious.

Note that this patch doesn't attempt to address the related issue
PR middle-end/20111, which is the need for the GCC nan* builtins
to handle non-ASCII character sets.

The following patch has been tested on x86_64-unknown-linux-gnu
with a full "make bootstrap", all default languages, and regression
tested with a top-level "make -k check" with no new failures.


Committed to mainline as revision 111470.



2006-02-26  Roger Sayle  <roger@eyesopen.com>

	PR middle-end/19983
	* real.c (real_nan): Allow both 0x and 0X as hexadecimal prefixes.

	* gcc.c-torture/execute/ieee/builtin-nan-1.c: New test case.


Index: real.c
===================================================================
*** real.c	(revision 111453)
--- real.c	(working copy)
*************** real_nan (REAL_VALUE_TYPE *r, const char
*** 2193,2200 ****
  	str++;
        if (*str == '0')
  	{
! 	  if (*++str == 'x')
! 	    str++, base = 16;
  	  else
  	    base = 8;
  	}
--- 2193,2204 ----
  	str++;
        if (*str == '0')
  	{
! 	  str++;
! 	  if (*str == 'x' || *str == 'X')
! 	    {
! 	      base = 16;
! 	      str++;
! 	    }
  	  else
  	    base = 8;
  	}


/* PR middle-end/19983 */

typedef __SIZE_TYPE__ size_t;

extern void abort(void);
extern int memcmp(const void *, const void *, size_t);

double n1 = __builtin_nan("0x1");
double n2 = __builtin_nan("0X1");

int main()
{
  if (memcmp (&n1, &n2, sizeof(double)))
    abort();
  return 0;
}


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]