[Bug math/34319] New: fromfp(INFINITY, ...) not NAN

"tydeman.fred at gmail dot com via Glibc-bugs" <[email protected]> Thu, 25 Jun 2026 02:02:38 +0000
Newsgroups gmane.comp.lib.glibc.bugs
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34319

            Bug ID: 34319
           Summary: fromfp(INFINITY, ...) not NAN
           Product: glibc
           Version: 2.41
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: tydeman.fred at gmail dot com
  Target Milestone: ---

This code fails:

#include <float.h>
#include <math.h>
#include <fenv.h>
#include <stdio.h>
#include <assert.h>

#pragma STDC FENV_ACCESS ON

int main(void){
  double d = fromfp( INFINITY, FP_INT_TOWARDZERO, 32 );
  (void)printf("%g\n", d);
  (void)fflush(stdout);
  assert( isnan(d) );
  return 0;
}


C23 has for fromfp():

Otherwise, if width is zero or x does not round to an integer within the range,
the functions return a NaN (of the type of the x argument, if available), else
the value of x, and a domain error occurs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.