Bug 21686 - tgmath.h handling of __int128
Summary: tgmath.h handling of __int128
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-28 14:09 UTC by Joseph Myers
Modified: 2017-08-02 20:17 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 Joseph Myers 2017-06-28 14:09:58 UTC
When a tgmath.h macro is passed a double argument and an argument of type __int128, it generates a call to a long double function (although the result still gets converted to type double).  __int128 is similar enough to integer types that it should be handled consistently like them, so always like double for these macros rather than sometimes like double and sometimes like long double.
Comment 1 Sourceware Commits 2017-08-02 20:17:12 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  42df8d5921d9ce28f44694ae943efb432b5e9aa7 (commit)
      from  b7f95f493b47abfd8f6320b3492b25a2beaa6aa1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=42df8d5921d9ce28f44694ae943efb432b5e9aa7

commit 42df8d5921d9ce28f44694ae943efb432b5e9aa7
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Aug 2 20:16:05 2017 +0000

    Fix tgmath.h for __int128 (bug 21686).
    
    When a tgmath.h macro is passed a double argument and an argument of
    type __int128, it generates a call to a long double function (although
    the result still gets converted to type double).  __int128 is similar
    enough to integer types that it should be handled consistently like
    them, so always like double for these macros rather than sometimes
    like double and sometimes like long double.  This patch fixes the
    logic accordingly and makes gen-tgmath-tests.py generate tests for
    __int128.
    
    Tested for x86_64 and x86.
    
    	[BZ #21686]
    	* math/tgmath.h (__TGMATH_BINARY_REAL_ONLY): Add arguments before
    	comparing size with that of double.
    	(__TGMATH_BINARY_REAL_STD_ONLY): Likewise.
    	(__TGMATH_BINARY_REAL_RET_ONLY): Likewise.
    	(__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise.
    	(__TGMATH_TERNARY_REAL_ONLY): Likewise.
    	(__TGMATH_BINARY_REAL_IMAG): Likewise.
    	* math/gen-tgmath-tests.py (Type.init_types): Create __int128 and
    	unsigned __int128 types.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |   13 +++++++++++++
 math/gen-tgmath-tests.py |    4 ++++
 math/tgmath.h            |   20 +++++++-------------
 3 files changed, 24 insertions(+), 13 deletions(-)
Comment 2 Joseph Myers 2017-08-02 20:17:52 UTC
Fixed for 2.27.