public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported
@ 2013-10-20 17:34 q1 at oxyba dot de
  2013-10-20 17:59 ` [Bug c++/58815] " daniel.kruegler at googlemail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: q1 at oxyba dot de @ 2013-10-20 17:34 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3860 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

            Bug ID: 58815
           Summary: Casting/Conversion operator for std::decimal not
                    supported
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: q1 at oxyba dot de

it is not really a bug a rather something missing. 

example:

#include<decimal/decimal>
int main(){
  std::decimal::decimal64 x(101.5001);
  long y = static_cast<long>(x); // throws an error
  return 0;
}

this will throw an error

"... error: invalid static_cast from type ‘std::decimal::decimal64’ to type
‘long int’..."


i know that type working would work using methods of std::decimal::decimal64,
e.g.

#include<decimal/decimal>
int main(){
  std::decimal::decimal64 x(101.5001);
  long long y = std::decimal::decimal64_to_long_long(x); // look here
  return 0;
}

As I cannot cicumvent the problem with outside class definition, I please you
to add conversion operators to std::decimal, e.g.

std::decimal::decimal64::operator long(){return ...;} 


In general std::decimal is really immature, e.g. no operator<<, not supported
in <traits> (it says std::decimal is a floating point).
>From gcc-bugs-return-432275-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Oct 20 17:55:58 2013
Return-Path: <gcc-bugs-return-432275-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26952 invoked by alias); 20 Oct 2013 17:55:57 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 26909 invoked by uid 48); 20 Oct 2013 17:55:55 -0000
From: "mikpelinux at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/58805] [4.8/4.9 Regression] Inline assembly wrongly optimized out when inside a conditional
Date: Sun, 20 Oct 2013 17:55:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: inline-asm
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mikpelinux at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.3
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc attachments.created
Message-ID: <bug-58805-4-HDmGDAKtVO@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58805-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58805-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01419.txt.bz2
Content-length: 636

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX805

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #9 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Created attachment 31055
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1055&actioníit
adjusted test case

Adjusted test case, aborts when the wrong-code occurs, exits 0 otherwise.  This
wrong-code started with r186447.  CC:ing author.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
@ 2013-10-20 17:59 ` daniel.kruegler at googlemail dot com
  2013-10-21 21:50 ` q1 at oxyba dot de
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-10-20 17:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The notion of "throws an error" is somewhat misleading in this context. What
you intend to describe is that the compiler rejects the code.
>From gcc-bugs-return-432277-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Oct 20 18:24:11 2013
Return-Path: <gcc-bugs-return-432277-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9282 invoked by alias); 20 Oct 2013 18:24:10 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 9250 invoked by uid 48); 20 Oct 2013 18:24:06 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
Date: Sun, 20 Oct 2013 18:24:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.7.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58815-4-zwnfp0JT1Z@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58815-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58815-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01421.txt.bz2
Content-length: 348

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX815

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In any case, keep in mind ulf that we are looking for help in this area: for
various reasons, the code isn't really maintained these days (eg, the original
implementor moved to another job, etc) Thus, contributions welcome!


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
  2013-10-20 17:59 ` [Bug c++/58815] " daniel.kruegler at googlemail dot com
@ 2013-10-21 21:50 ` q1 at oxyba dot de
  2013-10-21 23:38 ` janis at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: q1 at oxyba dot de @ 2013-10-21 21:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

ulf <q1 at oxyba dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janis187 at us dot ibm.com

--- Comment #3 from ulf <q1 at oxyba dot de> ---
i checked the code in the file decimal (/usr/include/c++/4.7/decimal/). The
programmer already considered conversion to integers. however the lines are
commented. 


for std::decimal::decimal32
...
line 253       // 3.2.2.5  Conversion to integral type. (DISABLED)
line 254       //operator long long() const { return (long long)__val; }
... 

for std::decimal::decimal64
...
line 336       // 3.2.3.5  Conversion to integral type. (DISABLED)
line 337       //operator long long() const { return (long long)__val; }
... 

for std::decimal::decimal128
...
line 420       // 3.2.4.5  Conversion to integral type. (DISABLED)
line 421       //operator long long() const { return (long long)__val; }
... 

i uncommented it and my problems were gone. but for some reason the code is
disabled on purpose. what is the reason for it?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
  2013-10-20 17:59 ` [Bug c++/58815] " daniel.kruegler at googlemail dot com
  2013-10-21 21:50 ` q1 at oxyba dot de
@ 2013-10-21 23:38 ` janis at gcc dot gnu.org
  2013-10-21 23:50 ` janis at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: janis at gcc dot gnu.org @ 2013-10-21 23:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #4 from Janis Johnson <janis at gcc dot gnu.org> ---
I vaguely remember a problem with those conversion and have no idea now what it
was, but I'll try to find something in the mailing list archives.

<decimal/decimal> includes a workaround:

  /// Non-conforming extension: Conversion to integral type.
  long long decimal32_to_long_long(decimal32 __d);
  long long decimal64_to_long_long(decimal64 __d);
  long long decimal128_to_long_long(decimal128 __d);
  long long decimal_to_long_long(decimal32 __d);
  long long decimal_to_long_long(decimal64 __d);
  long long decimal_to_long_long(decimal128 __d);


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (2 preceding siblings ...)
  2013-10-21 23:38 ` janis at gcc dot gnu.org
@ 2013-10-21 23:50 ` janis at gcc dot gnu.org
  2013-10-22  9:04 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: janis at gcc dot gnu.org @ 2013-10-21 23:50 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (3 preceding siblings ...)
  2013-10-21 23:50 ` janis at gcc dot gnu.org
@ 2013-10-22  9:04 ` paolo.carlini at oracle dot com
  2013-10-22  9:11 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22  9:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Janis. In C++11 we have *explicit* conversion operators. Would they
help? A safe approach woould providing the operators only in c++11 mode.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (4 preceding siblings ...)
  2013-10-22  9:04 ` paolo.carlini at oracle dot com
@ 2013-10-22  9:11 ` paolo.carlini at oracle dot com
  2013-10-22  9:12 ` daniel.kruegler at googlemail dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22  9:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Something like:

Index: include/decimal/decimal
===================================================================
--- include/decimal/decimal    (revision 203915)
+++ include/decimal/decimal    (working copy)
@@ -250,8 +250,10 @@
     /// Conforming extension: Conversion from scalar decimal type.
     decimal32(__decfloat32 __z)            : __val(__z) {}

-    // 3.2.2.5  Conversion to integral type. (DISABLED)
-    //operator long long() const { return (long long)__val; }
+#if __cplusplus >= 201103L
+    // 3.2.2.5  Conversion to integral type.
+    explicit operator long long() const { return (long long)__val; }
+#endif

     // 3.2.2.6  Increment and decrement operators.
     decimal32& operator++()
@@ -333,8 +335,10 @@
     /// Conforming extension: Conversion from scalar decimal type.
     decimal64(__decfloat64 __z)            : __val(__z) {}

-    // 3.2.3.5  Conversion to integral type. (DISABLED)
-    //operator long long() const { return (long long)__val; }
+#if __cplusplus >= 201103L
+    // 3.2.3.5  Conversion to integral type.
+    explicit operator long long() const { return (long long)__val; }
+#endif

     // 3.2.3.6  Increment and decrement operators.
     decimal64& operator++()
@@ -417,8 +421,10 @@
     /// Conforming extension: Conversion from scalar decimal type.
     decimal128(__decfloat128 __z)        : __val(__z) {}

-    // 3.2.4.5  Conversion to integral type. (DISABLED)
-    //operator long long() const { return (long long)__val; }
+#if __cplusplus >= 201103L
+    // 3.2.4.5  Conversion to integral type.
+    explicit operator long long() const { return (long long)__val; }
+#endif

     // 3.2.4.6  Increment and decrement operators.
     decimal128& operator++()


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (5 preceding siblings ...)
  2013-10-22  9:11 ` paolo.carlini at oracle dot com
@ 2013-10-22  9:12 ` daniel.kruegler at googlemail dot com
  2013-10-22 15:29 ` janis at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-10-22  9:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #8 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Paolo Carlini from comment #6)
I also would like to encourage using explicit conversion functions. This is
explicitly suggested in the updated C++11 integration document:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3407.html
>From gcc-bugs-return-432444-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 09:36:18 2013
Return-Path: <gcc-bugs-return-432444-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3781 invoked by alias); 22 Oct 2013 09:36:17 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3713 invoked by uid 48); 22 Oct 2013 09:36:12 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58772] __attribute__((aligned(16))) and nested classes cause -ftree-vectorize to generate segfaulting code
Date: Tue, 22 Oct 2013 09:36:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58772-4-pAPwWOuKqy@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58772-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58772-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01588.txt.bz2
Content-length: 430

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX772

--- Comment #8 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> Paolo, does libstdc++ provide a custom allocator for aligned memory?

PR 55727

> Is this issue going to be resolved with C++1y?

There is a NB comment requesting the inclusion of N3396 in C++14, but that
seems unlikely at this point. Hopefully C++17, as Paolo says.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (6 preceding siblings ...)
  2013-10-22  9:12 ` daniel.kruegler at googlemail dot com
@ 2013-10-22 15:29 ` janis at gcc dot gnu.org
  2013-10-22 15:43 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: janis at gcc dot gnu.org @ 2013-10-22 15:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #9 from Janis Johnson <janis at gcc dot gnu.org> ---
I haven't paid attention to decimal float since leaving IBM, so it was very
interesting to see the updated C++11 working paper.  It makes sense to me to
use C++11 functionality in the GNU C++ decimal float support, especially in the
case of explicit conversions.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (7 preceding siblings ...)
  2013-10-22 15:29 ` janis at gcc dot gnu.org
@ 2013-10-22 15:43 ` paolo.carlini at oracle dot com
  2013-10-22 17:43 ` q1 at oxyba dot de
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22 15:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-10-22
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
     Ever confirmed|0                           |1

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Ah good, thanks Janis. Thus let's add in C++11 mode these explicit operators
with a comment pointing to n3407. More than that is beyond the scope of this PR
but it would be nice if somebody volunteers to follow the topic, prepares
patches, etc.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (8 preceding siblings ...)
  2013-10-22 15:43 ` paolo.carlini at oracle dot com
@ 2013-10-22 17:43 ` q1 at oxyba dot de
  2013-10-22 18:07 ` janis at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: q1 at oxyba dot de @ 2013-10-22 17:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #11 from ulf <q1 at oxyba dot de> ---
i see evil implicit conversion. 

i modified lines 254, 337 and 421 to 

explicit operator long long() const { return (long long)__val; }

like suggested in n3407.



#include<decimal/decimal>
int main(){
  std::decimal::decimal32 x(101.5051);
  long long a = (long long)x; // OK
  long long b = static_cast<long long>(x); // OK
  //long long c = x; // error
  //long d = (long)x; // error
  //long e = static_cast<long>(x); // error

  std::decimal::decimal64 y(101.5051);
  long long f = (long long)y; // OK
  long long g = static_cast<long long>(y); // OK
  //long long h = y; // error
  //long i = (long)y; // error
  //long j = static_cast<long>(y); // error

  std::decimal::decimal128 z(101.5051);
  long long k = (long long)z; // OK
  long long l = static_cast<long long>(z); // OK
  //long long m = z; // error
  //long n = (long)z; // error
  //long o = static_cast<long>(z); // error
  return 0;
}


some other issues regarding std::decimal

std::is_decimal_floating_point<std::decimal::decimalXXX> in type_traits 

see page 7, chapter 3.11.1 and 2 (page 62) in
www.open-std.org/jtc1/sc22/open/n4112.pdf

std::numeric_limits<std::decimal::decimalXXX> in limits

see chapter 3.3 in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (9 preceding siblings ...)
  2013-10-22 17:43 ` q1 at oxyba dot de
@ 2013-10-22 18:07 ` janis at gcc dot gnu.org
  2013-10-22 18:20 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: janis at gcc dot gnu.org @ 2013-10-22 18:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #12 from Janis Johnson <janis at gcc dot gnu.org> ---
I obviously don't know C++ very well and the decimal float support in libstdc++
is very ugly.  It would be nice if someone rewrites it in actual C++ someday;
the tests should help with that effort.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug c++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (10 preceding siblings ...)
  2013-10-22 18:07 ` janis at gcc dot gnu.org
@ 2013-10-22 18:20 ` paolo.carlini at oracle dot com
  2013-10-22 20:02 ` [Bug libstdc++/58815] " paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22 18:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #13 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thus, let's make a decision: either this is a bug, importance <minor> as
submitted, about conversions to integer, as appeared to be, or it's a catch all
bug about all the issues with the TR decimal + all the work toward a C++17
standard facility.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (11 preceding siblings ...)
  2013-10-22 18:20 ` paolo.carlini at oracle dot com
@ 2013-10-22 20:02 ` paolo.carlini at oracle dot com
  2013-10-23 11:48 ` paolo at gcc dot gnu.org
  2013-10-23 11:50 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22 20:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #15 from Paolo Carlini <paolo.carlini at oracle dot com> ---
A maintainer is also needed in order to *categorize* those potential issues and
plan the work: for example C++11 (+ C++14), which are the primary standards
which we are implementing, don't know about decimal, thus isn't at all clear
that we can conformingly add stuff (thus names) to <type_traits>. More
generally, at this point, that TR is pretty old, isn't clear that we want to
improve the TR code vs freezing it and start work toward providing under some
sort of experimental mode, well separate from standard C++14, something close
to the recent proposal written by Dietmar. See what I mean? If the issue is
just "uncommenting" an operator which essentially was already there and now
thanks to explicit operators in C++11 we know how to do right, that we can do
right now.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (12 preceding siblings ...)
  2013-10-22 20:02 ` [Bug libstdc++/58815] " paolo.carlini at oracle dot com
@ 2013-10-23 11:48 ` paolo at gcc dot gnu.org
  2013-10-23 11:50 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-10-23 11:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

--- Comment #16 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Wed Oct 23 11:48:26 2013
New Revision: 203956

URL: http://gcc.gnu.org/viewcvs?rev=203956&root=gcc&view=rev
Log:
2013-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/58815
    * include/decimal/decimal (decimal32::operator long long(),
    decimal64::operator long long(), decimal128::operator long long()):
    Add in c++11 mode per n3407.
    * testsuite/decimal/pr58815.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/decimal/pr58815.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/decimal/decimal


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/58815] Casting/Conversion operator for std::decimal not supported
  2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
                   ` (13 preceding siblings ...)
  2013-10-23 11:48 ` paolo at gcc dot gnu.org
@ 2013-10-23 11:50 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-23 11:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58815

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #17 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-10-23 11:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-20 17:34 [Bug c++/58815] New: Casting/Conversion operator for std::decimal not supported q1 at oxyba dot de
2013-10-20 17:59 ` [Bug c++/58815] " daniel.kruegler at googlemail dot com
2013-10-21 21:50 ` q1 at oxyba dot de
2013-10-21 23:38 ` janis at gcc dot gnu.org
2013-10-21 23:50 ` janis at gcc dot gnu.org
2013-10-22  9:04 ` paolo.carlini at oracle dot com
2013-10-22  9:11 ` paolo.carlini at oracle dot com
2013-10-22  9:12 ` daniel.kruegler at googlemail dot com
2013-10-22 15:29 ` janis at gcc dot gnu.org
2013-10-22 15:43 ` paolo.carlini at oracle dot com
2013-10-22 17:43 ` q1 at oxyba dot de
2013-10-22 18:07 ` janis at gcc dot gnu.org
2013-10-22 18:20 ` paolo.carlini at oracle dot com
2013-10-22 20:02 ` [Bug libstdc++/58815] " paolo.carlini at oracle dot com
2013-10-23 11:48 ` paolo at gcc dot gnu.org
2013-10-23 11:50 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).