This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]