[cfe-commits] [PATCH] Use proper postfix for predefined DBL_* and LDBL_*

Logan Chien tzuhsiang.chien at gmail.com
Tue Sep 11 22:28:25 PDT 2012


Dear all,

  The type of LDBL_MIN, LDBL_MAX, LDBL_DENORM, and LDBL_EPSILO
are not always equal to "long double" on every architecture (ARM or MIPS).
This will cause some problem in overloaded method resolution and template
instantiation.

For example, here's a piece of simplified code from STLport:

template <class _Tp>
static complex<_Tp> tanT(const complex<_Tp>& z, const _Tp& Tp_limit) { ... }

complex<long double> tan(const complex<long double>& z)
{ return tanT(z, *::log(LDBL_MAX)*); }

  Since LDBL_MAX is defined as a double-typed literal, the compiler will
choose *double ::log(double)* in the overloaded method resolution.  Then,
we will call tanT(const complex<*long double*>&, *double*),
which is undefined (or precisely, bailed the template instantiation).

  Although the C/C++ standards do not specified the type of the LDBL_*,
however I believe we should define them as long double, regardless the
target
implementation for long double.  This is also the behaviour documented in
the glibc document<http://www.gnu.org/software/libc/manual/html_mono/libc.html#Floating-Point-Parameters>
.

  I hope the attached patch can fix this issue.  Please have a look.
Thanks.

Sincerely,
Logan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120912/ca200a01/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Use-proper-literal-postfix-for-DBL_-and-LDBL_.patch
Type: application/octet-stream
Size: 17977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120912/ca200a01/attachment.obj>


More information about the cfe-commits mailing list