public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio
@ 2023-07-08  5:01 hewillk at gmail dot com
  2023-07-08  7:20 ` [Bug libstdc++/110593] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hewillk at gmail dot com @ 2023-07-08  5:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

            Bug ID: 110593
           Summary: The std::ratio meta arithmetic can accept
                    non-std::ratio
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

[ratio.general]: "If a template parameter is named R1 or R2, and the template
argument is not a specialization of the ratio template, the program is
ill-formed."

So for the following libstdc++ needs to be diagnosed, right?

#include <ratio>

struct Ratio { constexpr static double num = 0, den = 1; };
static_assert(std::ratio_equal<Ratio, std::ratio<0, 5>>());

https://godbolt.org/z/MhazY5ecn

Only MSVC-STL triggers the static assertion.

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
@ 2023-07-08  7:20 ` redi at gcc dot gnu.org
  2023-07-19 18:23 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-08  7:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-07-08
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
  2023-07-08  7:20 ` [Bug libstdc++/110593] " redi at gcc dot gnu.org
@ 2023-07-19 18:23 ` redi at gcc dot gnu.org
  2023-07-19 22:43 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-19 18:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
  2023-07-08  7:20 ` [Bug libstdc++/110593] " redi at gcc dot gnu.org
  2023-07-19 18:23 ` redi at gcc dot gnu.org
@ 2023-07-19 22:43 ` cvs-commit at gcc dot gnu.org
  2023-07-19 23:33 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-19 22:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:2d614822e9ea2a3d8800045d66e3220743753d09

commit r14-2660-g2d614822e9ea2a3d8800045d66e3220743753d09
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 19 18:18:46 2023 +0100

    libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]

    The standard says that it should be ill-formed to use std::ratio_equal
    etc. with types which are not specializations of std::ratio. This
    implements that requirement.

    We don't need to add assertions to every one of the class templates,
    because many of them are implemented in terms of other ones. For
    example, ratio_divide and ratio_subtract can rely on the assertions in
    ratio_multiply and ratio_add respectively.

    libstdc++-v3/ChangeLog:

            PR libstdc++/110593
            * include/bits/chrono.h (duration): Improve static assert
            messages.
            (__is_ratio): Move to ...
            * include/std/ratio (__is_ratio): ... here.
            (__is_ratio_v): New variable template and partial
            specialization.
            (__are_both_ratios): New function template.
            (__ratio_multiply, ratio_equal, ratio_less, __ratio_add):
            Add static assertion.
            * testsuite/20_util/ratio/requirements/type_constraints.cc:
            New test.
            * testsuite/20_util/duration/requirements/typedefs_neg1.cc:
            Adjust expected error.
            * testsuite/20_util/duration/requirements/typedefs_neg2.cc:
            Likewise.

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2023-07-19 22:43 ` cvs-commit at gcc dot gnu.org
@ 2023-07-19 23:33 ` redi at gcc dot gnu.org
  2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-19 23:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

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

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 14. Thanks for the report.

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2023-07-19 23:33 ` redi at gcc dot gnu.org
@ 2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org
  2024-03-18 14:04 ` cvs-commit at gcc dot gnu.org
  2024-03-18 14:11 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-28 17:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:13dd1501a1adc5d76c13ae36368bff3c3b64da37

commit r13-7627-g13dd1501a1adc5d76c13ae36368bff3c3b64da37
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 19 18:18:46 2023 +0100

    libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]

    The standard says that it should be ill-formed to use std::ratio_equal
    etc. with types which are not specializations of std::ratio. This
    implements that requirement.

    We don't need to add assertions to every one of the class templates,
    because many of them are implemented in terms of other ones. For
    example, ratio_divide and ratio_subtract can rely on the assertions in
    ratio_multiply and ratio_add respectively.

    libstdc++-v3/ChangeLog:

            PR libstdc++/110593
            * include/bits/chrono.h (duration): Improve static assert
            messages.
            (__is_ratio): Move to ...
            * include/std/ratio (__is_ratio): ... here.
            (__is_ratio_v): New variable template and partial
            specialization.
            (__are_both_ratios): New function template.
            (__ratio_multiply, ratio_equal, ratio_less, __ratio_add):
            Add static assertion.
            * testsuite/20_util/ratio/requirements/type_constraints.cc:
            New test.
            * testsuite/20_util/duration/requirements/typedefs_neg1.cc:
            Adjust expected error.
            * testsuite/20_util/duration/requirements/typedefs_neg2.cc:
            Likewise.

    (cherry picked from commit 2d614822e9ea2a3d8800045d66e3220743753d09)

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org
@ 2024-03-18 14:04 ` cvs-commit at gcc dot gnu.org
  2024-03-18 14:11 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-18 14:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:ae8302e18f15f0befb372762b20a3a790a19a925

commit r12-10238-gae8302e18f15f0befb372762b20a3a790a19a925
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 19 18:18:46 2023 +0100

    libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]

    The standard says that it should be ill-formed to use std::ratio_equal
    etc. with types which are not specializations of std::ratio. This
    implements that requirement.

    We don't need to add assertions to every one of the class templates,
    because many of them are implemented in terms of other ones. For
    example, ratio_divide and ratio_subtract can rely on the assertions in
    ratio_multiply and ratio_add respectively.

    libstdc++-v3/ChangeLog:

            PR libstdc++/110593
            * include/bits/chrono.h (duration): Improve static assert
            messages.
            (__is_ratio): Move to ...
            * include/std/ratio (__is_ratio): ... here.
            (__is_ratio_v): New variable template and partial
            specialization.
            (__are_both_ratios): New function template.
            (__ratio_multiply, ratio_equal, ratio_less, __ratio_add):
            Add static assertion.
            * testsuite/20_util/ratio/requirements/type_constraints.cc:
            New test.
            * testsuite/20_util/duration/requirements/typedefs_neg1.cc:
            Adjust expected error.
            * testsuite/20_util/duration/requirements/typedefs_neg2.cc:
            Likewise.

    (cherry picked from commit 2d614822e9ea2a3d8800045d66e3220743753d09)

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

* [Bug libstdc++/110593] The std::ratio meta arithmetic can accept non-std::ratio
  2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2024-03-18 14:04 ` cvs-commit at gcc dot gnu.org
@ 2024-03-18 14:11 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-18 14:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110593

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |12.4

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Also fixed for 13.3 and 12.4

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

end of thread, other threads:[~2024-03-18 14:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-08  5:01 [Bug libstdc++/110593] New: The std::ratio meta arithmetic can accept non-std::ratio hewillk at gmail dot com
2023-07-08  7:20 ` [Bug libstdc++/110593] " redi at gcc dot gnu.org
2023-07-19 18:23 ` redi at gcc dot gnu.org
2023-07-19 22:43 ` cvs-commit at gcc dot gnu.org
2023-07-19 23:33 ` redi at gcc dot gnu.org
2023-07-28 17:32 ` cvs-commit at gcc dot gnu.org
2024-03-18 14:04 ` cvs-commit at gcc dot gnu.org
2024-03-18 14:11 ` redi at gcc dot gnu.org

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).