Bug 26073 - getpayload() has wrong return value
Summary: getpayload() has wrong return value
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.32
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-02 18:40 UTC by Fred Tydeman
Modified: 2020-07-31 09:09 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Tydeman 2020-06-02 18:40:55 UTC
/*
 * getpayload() bug
 * C2X has in F.10.13.1: If *x is not a NaN, the return result is -1.
 */
#define __STDC_WANT_IEC_60559_BFP_EXT__
#include <math.h>
#include <stdio.h>

int main(void){
  double d = 1.0;
  d = getpayload( &d );	/* not a NaN argument */
  if(-1.0 != d) (void)printf("Bug: d=%g\n", d);
  return 0;
}
Comment 1 Joseph Myers 2020-07-06 16:29:43 UTC
Fixed for 2.32.

commit 6c010c5dde1735f93cc3a6597cdcc2b482af85f8
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Mon Jul 6 16:18:02 2020 +0000

    Use C2x return value from getpayload of non-NaN (bug 26073).
    
    In TS 18661-1, getpayload had an unspecified return value for a
    non-NaN argument, while C2x requires the return value -1 in that case.
    
    This patch implements the return value of -1.  I don't think this is
    worth having a new symbol version that's an alias of the old one,
    although occasionally we do that in such cases where the new function
    semantics are a refinement of the old ones (to avoid programs relying
    on the new semantics running on older glibc versions but not behaving
    as intended).
    
    Tested for x86_64 and x86; also ran math/ tests for aarch64 and
    powerpc.