public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-20 19:44 ` redi at gcc dot gnu.org
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-20 19:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
2020-08-20 19:44 ` [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions redi at gcc dot gnu.org
@ 2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
--- Comment #4 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:3eefb302d2bd8502cb3d8fe44e672b11092ccaf6
commit r11-2881-g3eefb302d2bd8502cb3d8fe44e672b11092ccaf6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 14:47:51 2020 +0100
libstdc++: Enable assertions in constexpr string_view members [PR 71960]
Since GCC 6.1 there is no reason we can't just use __glibcxx_assert in
constexpr functions in string_view. As long as the condition is true,
there will be no call to std::__replacement_assert that would make the
function ineligible for constant evaluation.
PR libstdc++/71960
* include/experimental/string_view (basic_string_view):
Enable debug assertions.
* include/std/string_view (basic_string_view):
Likewise.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
2020-08-20 19:44 ` [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions redi at gcc dot gnu.org
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
@ 2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
2020-08-26 13:50 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:85847fd421d7760f45f0e69c7ae3607f2f898bb8
commit r10-8676-g85847fd421d7760f45f0e69c7ae3607f2f898bb8
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 14:47:51 2020 +0100
libstdc++: Enable assertions in constexpr string_view members [PR 71960]
Since GCC 6.1 there is no reason we can't just use __glibcxx_assert in
constexpr functions in string_view. As long as the condition is true,
there will be no call to std::__replacement_assert that would make the
function ineligible for constant evaluation.
PR libstdc++/71960
* include/experimental/string_view (basic_string_view):
Enable debug assertions.
* include/std/string_view (basic_string_view):
Likewise.
(cherry picked from commit 3eefb302d2bd8502cb3d8fe44e672b11092ccaf6)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
@ 2020-08-26 13:50 ` cvs-commit at gcc dot gnu.org
2020-09-01 19:55 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:42fb390082b59c0b5af6a9f1e5a2e608ccb8e193
commit r9-8833-g42fb390082b59c0b5af6a9f1e5a2e608ccb8e193
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 14:47:51 2020 +0100
libstdc++: Enable assertions in constexpr string_view members [PR 71960]
Since GCC 6.1 there is no reason we can't just use __glibcxx_assert in
constexpr functions in string_view. As long as the condition is true,
there will be no call to std::__replacement_assert that would make the
function ineligible for constant evaluation.
PR libstdc++/71960
* include/experimental/string_view (basic_string_view):
Enable debug assertions.
* include/std/string_view (basic_string_view):
Likewise.
(cherry picked from commit 3eefb302d2bd8502cb3d8fe44e672b11092ccaf6)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2020-08-26 13:50 ` cvs-commit at gcc dot gnu.org
@ 2020-09-01 19:55 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:52 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:59 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-01 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
--- Comment #7 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:10f51543bb81cc953792270b40a9c812049e8b4c
commit r11-2971-g10f51543bb81cc953792270b40a9c812049e8b4c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Sep 1 20:52:26 2020 +0100
libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
This change evaluates __glibcxx_assert checks unconditionally when a
function is being constant evaluated (when std::is_constant_evaluated()
is true). If the check fails, compilation will fail with an error.
If the function isn't being constant evaluated, the normal runtime check
will be done if enabled by _GLIBCXX_ASSERTIONS or _GLIBCXX_DEBUG, the
same as before.
Tangentially, the __glibcxx_assert and _GLIBCXX_PARALLEL_ASSERT macros
are changed to expand to 'do { } while (false)' when assertions are
disabled, instead of expanding to nothing. This avoids -Wempty-body
warnings when a disabled assertion is used in an 'if' or 'else'
statement e.g.
if constexpr (/* precondition is testable */)
__glibcxx_assert(precondition);
a.C:9:27: warning: suggest braces around empty body in an âifâ
statement [-Wempty-body]
9 | __glibcxx_assert(precondition);
| ^
libstdc++-v3/ChangeLog:
PR libstdc++/71960
* include/bits/c++config (__glibcxx_assert_impl): Remove
do-while so that uses of the macro need to add it.
(__glibcxx_assert): Rename macro for runtime assertions
to __glibcxx_assert_2.
(__glibcxx_assert_1): Define macro for constexpr assertions.
(__glibcxx_assert): Define macro for constexpr and runtime
assertions.
* include/bits/range_access.h (ranges::advance): Remove
redundant precondition checks during constant evaluation.
* include/parallel/base.h (_GLIBCXX_PARALLEL_ASSERT): Always
use do-while in macro expansion.
* include/std/ranges (iota_view::iota_view(W, B)): Remove
redundant braces.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2020-09-01 19:55 ` cvs-commit at gcc dot gnu.org
@ 2020-09-11 10:52 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:59 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-11 10:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:877cdcc714704e242f477580d81397cc1d0fc90e
commit r8-10444-g877cdcc714704e242f477580d81397cc1d0fc90e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Sep 10 15:49:26 2020 +0100
libstdc++: Enable assertions in constexpr string_view members [PR 71960]
There is no longer any reason we can't just use __glibcxx_assert in
constexpr functions. As long as the condition is true, there will be no
call to std::__replacement_assert that would make the function
ineligible for constant evaluation.
PR libstdc++/71960
* include/experimental/string_view (basic_string_view):
Enable debug assertions.
* include/std/string_view (basic_string_view):
Likewise.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2020-09-11 10:52 ` cvs-commit at gcc dot gnu.org
@ 2020-09-11 10:59 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-11 10:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71960
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think these assertions should always have been OK in constexpr functions, but
G++ was incorrectly evaluating the untaken branch. That has been fixed for some
time, so the checks work. The commented out checks in string_view have been
enabled on all branches, and on trunk the assertions are now unconditionally
checked during constant evaluation, not only when _GLIBCXX_ASSERTIONS is
defined.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-11 10:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-71960-4@http.gcc.gnu.org/bugzilla/>
2020-08-20 19:44 ` [Bug libstdc++/71960] __glibcxx_assert and Debug Mode checks can't be used in constexpr functions redi at gcc dot gnu.org
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
2020-08-26 13:49 ` cvs-commit at gcc dot gnu.org
2020-08-26 13:50 ` cvs-commit at gcc dot gnu.org
2020-09-01 19:55 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:52 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:59 ` 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).