public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
@ 2013-03-21 13:00 npl at chello dot at
  2013-03-21 13:17 ` [Bug libstdc++/56677] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: npl at chello dot at @ 2013-03-21 13:00 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56677
           Summary: [ratio] : ratio_multiply, ratio_divide, etc results
                    doesnt verify as __is_ratio
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: npl@chello.at


within chrono there is a test for template parameters if they classify as
ratios: __is_ratio
this test only works if the type is constructed as ratio<>, but the arithmetic
functions on ratio ratio_multiply, ratio_divide, .. dont generate the result
this way.

Here is a little programm to illustrate the issue:

------------------------------------------------------------------
#include <ratio>
#include <chrono>

typedef std::ratio_divide<std::ratio<1>, std::ratio<1> > ratii1;
typedef std::ratio<ratii1::num,ratii1::den > ratii2;

std::chrono::duration<unsigned long, ratii1 > d1; // compile time check raises
error
std::chrono::duration<unsigned long, ratii2 > d2; // works fine.
------------------------------------------------------------------

the solution would be either to make the  __is_ratio smarter or, just generate
results like I did with ratii2.


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

* [Bug libstdc++/56677] [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
  2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
@ 2013-03-21 13:17 ` redi at gcc dot gnu.org
  2013-03-21 13:44 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-21 13:17 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-21 13:17:15 UTC ---
This is because ratio_divide is a struct, as required by earlier C++0x drafts,
not an alias template as required by the final standard. It's already fixed for
4.8


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

* [Bug libstdc++/56677] [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
  2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
  2013-03-21 13:17 ` [Bug libstdc++/56677] " redi at gcc dot gnu.org
@ 2013-03-21 13:44 ` redi at gcc dot gnu.org
  2013-03-21 14:38 ` npl at chello dot at
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-21 13:44 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to work|                            |4.8.0

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-21 13:44:21 UTC ---
The workaround is simply:

std::chrono::duration<unsigned long, ratii1::type > d1;

I don't think we want to backport the fix, as it would break compatibility with
existing 4.7.x releases.


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

* [Bug libstdc++/56677] [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
  2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
  2013-03-21 13:17 ` [Bug libstdc++/56677] " redi at gcc dot gnu.org
  2013-03-21 13:44 ` redi at gcc dot gnu.org
@ 2013-03-21 14:38 ` npl at chello dot at
  2013-03-21 15:35 ` redi at gcc dot gnu.org
  2013-06-11  9:01 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: npl at chello dot at @ 2013-03-21 14:38 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from npl at chello dot at 2013-03-21 14:38:48 UTC ---
Thanks, this did not occur to me.
Still, wouldnt it be relatively easy to adopt the __is_ratio function to check
for the ::type instead?


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

* [Bug libstdc++/56677] [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
  2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
                   ` (2 preceding siblings ...)
  2013-03-21 14:38 ` npl at chello dot at
@ 2013-03-21 15:35 ` redi at gcc dot gnu.org
  2013-06-11  9:01 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-21 15:35 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-21 15:35:46 UTC ---
That wouldn't help. The requirement is that the Period template argument is a
ratio. In GCC 4.7 ratio_divide is not a ratio.  Whether ratio_divide::type is a
ratio or not doesn't change the fact that ratio_divide is not a ratio and
therefore not a suitable template argument for duration.

To make it work we'd also need to make duration::period a typedef for either
_Period or _Period::type and alter the two static assertions to use period not
_Period, which is doable but I'm not convinced it's worth fixing in the stable
release branch.  I might look into it later.


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

* [Bug libstdc++/56677] [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio
  2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
                   ` (3 preceding siblings ...)
  2013-03-21 15:35 ` redi at gcc dot gnu.org
@ 2013-06-11  9:01 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-11  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.8.0.


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

end of thread, other threads:[~2013-06-11  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-21 13:00 [Bug libstdc++/56677] New: [ratio] : ratio_multiply, ratio_divide, etc results doesnt verify as __is_ratio npl at chello dot at
2013-03-21 13:17 ` [Bug libstdc++/56677] " redi at gcc dot gnu.org
2013-03-21 13:44 ` redi at gcc dot gnu.org
2013-03-21 14:38 ` npl at chello dot at
2013-03-21 15:35 ` redi at gcc dot gnu.org
2013-06-11  9:01 ` 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).