[Bug c++/58815] Casting/Conversion operator for std::decimal not supported
janis at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Oct 21 23:50:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815
--- Comment #5 from Janis Johnson <janis at gcc dot gnu.org> ---
>From Janis in http://gcc.gnu.org/ml/libstdc++/2009-09/msg00115.html
The TR defines, within each of the classes decimal32, decimal64, and
decimal128, the following conversion:
// 3.2.[234].4 conversion to integral type:
operator long long() const;
Apparently there's a way to implement this if one knows enough about
C++, but providing this implicit conversion from a decimal float type to
long long allows further implicit conversions from long long to other
types, including float, double, and long double, which are not supposed
to be allowed. Furthermore, a conversion from a decimal float type to a
generic float type that goes through long long truncates the fractional
part of the value which is rather surprising. This version of the patch
leaves out that conversion and provides a set of functions to convert to
long long, which made testing the rest of the functionality much easier.
Any suggestions for how to do with using the current (not C++0x)
standard? Or is it OK to require the use of C++0x functionality with
this extension?
>From Benjamin Kosnik in http://gcc.gnu.org/ml/libstdc++/2009-09/msg00127.html
I think it is not ok to require the use of C++0x with the
decimal floating point extension. It is clearly designed with C++2003 in
mind, and makes no use of C++0x features.
When you post testsuite files demonstrating this issue in detail I'll
take a look at this overload issue.
>From Janis in http://gcc.gnu.org/ml/libstdc++/2009-10/msg00004.html
With the submission on Monday I mentioned that this patch does not
support an implicit conversion to integral types (long long) from each
of the decimal classes. Those are in the patch, commented out and with
a comment that now says (DISABLED). If those are not disabled then all
of the error checks in the bad-*.cc tests fail. I can't see how to
allow implicit conversions to long long while also prohibiting bitwise
operations with decimal floating-point operands or conversions and
casts to generic floating-point types.
I didn't find any further discussion of this issue.
More information about the Gcc-bugs
mailing list