Fix parameter type in C++ version of iseqsig (bug 23171)

Message ID 20180514142858.26953-1-gabriel@inconstante.eti.br
State New
Headers show
Series
  • Fix parameter type in C++ version of iseqsig (bug 23171)
Related show

Commit Message

Gabriel F. T. Gomes May 14, 2018, 2:28 p.m.
The commit

  commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
  Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
  Date:   Fri Nov 3 10:44:36 2017 -0200

      Provide a C++ version of iseqsig (bug 22377)

mistakenly used double parameters in the long double version of iseqsig,
thus causing spurious conversions to double, as reported on bug 23171.

Tested for powerpc64le and x86_64.

	[BZ #23171]
	* math/math.h [C++] (iseqsig): Fix parameter type for the long
	double version.
---
 math/math.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gabriel F. T. Gomes May 14, 2018, 2:30 p.m. | #1
On Mon, 14 May 2018, Gabriel F. T. Gomes wrote:

>mistakenly used double parameters in the long double version of iseqsig,
>thus causing spurious conversions to double, as reported on bug 23171.

By the way, is there any kind of test, which could be added to the test
suite, and that would have detected such spurious conversions?
Joseph Myers May 14, 2018, 3:15 p.m. | #2
On Mon, 14 May 2018, Gabriel F. T. Gomes wrote:

> The commit
> 
>   commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
>   Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
>   Date:   Fri Nov 3 10:44:36 2017 -0200
> 
>       Provide a C++ version of iseqsig (bug 22377)
> 
> mistakenly used double parameters in the long double version of iseqsig,
> thus causing spurious conversions to double, as reported on bug 23171.
> 
> Tested for powerpc64le and x86_64.
> 
> 	[BZ #23171]
> 	* math/math.h [C++] (iseqsig): Fix parameter type for the long
> 	double version.

OK.
Joseph Myers May 14, 2018, 3:16 p.m. | #3
On Mon, 14 May 2018, Gabriel F. T. Gomes wrote:

> On Mon, 14 May 2018, Gabriel F. T. Gomes wrote:
> 
> >mistakenly used double parameters in the long double version of iseqsig,
> >thus causing spurious conversions to double, as reported on bug 23171.
> 
> By the way, is there any kind of test, which could be added to the test
> suite, and that would have detected such spurious conversions?

I would guess something like

  volatile long double a = LDBL_MAX;
  volatile long double b = nextdownl (a);
  /* Then test a and b do not compare equal with iseqsig.  */

(not tested that this does indeed fail before and pass after the fix when 
compiled as C++ on a platform where long double is wider than double).
Gabriel F. T. Gomes May 24, 2018, 6:48 p.m. | #4
On Mon, 14 May 2018, Joseph Myers wrote:

>On Mon, 14 May 2018, Gabriel F. T. Gomes wrote:
>
>> The commit
>> 
>>   commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
>>   Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
>>   Date:   Fri Nov 3 10:44:36 2017 -0200
>> 
>>       Provide a C++ version of iseqsig (bug 22377)
>> 
>> mistakenly used double parameters in the long double version of iseqsig,
>> thus causing spurious conversions to double, as reported on bug 23171.
>> 
>> Tested for powerpc64le and x86_64.
>> 
>> 	[BZ #23171]
>> 	* math/math.h [C++] (iseqsig): Fix parameter type for the long
>> 	double version.  
>
>OK.

Thanks.  Now pushed as fb0e10b8eb1e.  I'll wait some days, then I can
backport this fix to 2.26 and 2.27.

Patch

diff --git a/math/math.h b/math/math.h
index 87240336e0..ddee4e4083 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1511,7 +1511,7 @@  template<> struct __iseqsig_type<double>
 
 template<> struct __iseqsig_type<long double>
 {
-  static int __call (double __x, double __y) throw ()
+  static int __call (long double __x, long double __y) throw ()
   {
 #  ifndef __NO_LONG_DOUBLE_MATH
     return __iseqsigl (__x, __y);