<tgmath.h> bug for binary and ternary functions with int and float arguments

Joseph S. Myers joseph@codesourcery.com
Tue Mar 29 19:05:00 GMT 2005


The definitions in <tgmath.h> of __TGMATH_BINARY_REAL_ONLY, 
__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY, __TGMATH_TERNARY_REAL_ONLY, 
__TGMATH_BINARY_REAL_IMAG are buggy when the function has arguments of 
type float and an integer type.  If any argument is of integer type then 
the function chosen should be that for double or long double according to 
whether any other argument has type long double, not that for float even 
if all other arguments have type float, and the type of the result should 
be determined accordingly.  For example,

  int x;
  float y;
  sizeof(pow(x, y)); // Has value sizeof(double).

I believe __typeof((__tgmath_real_type(Val1))0 + 
(__tgmath_real_type(Val2))0) should be used in place of __tgmath_real_type 
((Val1) + (Val2)), and similarly for ternary functions.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list