public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-6126] libstdc++: Disable __gnu_debug::__is_singular(T*) in constexpr [PR109517]
@ 2024-12-11 21:55 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2024-12-11 21:55 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:9616deb23a17ebe81ad89ede191d7f9f752abdec

commit r15-6126-g9616deb23a17ebe81ad89ede191d7f9f752abdec
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Dec 10 10:56:41 2024 +0000

    libstdc++: Disable __gnu_debug::__is_singular(T*) in constexpr [PR109517]
    
    Because of PR c++/85944 we have several bugs where _GLIBCXX_DEBUG causes
    errors for constexpr code. Although Bug 117966 could be fixed by
    avoiding redundant debug checks in std::span, and Bug 106212 could be
    fixed by avoiding redundant debug checks in std::array, there are many
    more cases where similar __glibcxx_requires_valid_range checks fail to
    compile and removing the checks everywhere isn't desirable.
    
    This just disables the __gnu_debug::__check_singular(T*) check during
    constant evaluation. Attempting to dereference a null pointer will
    certainly fail during constant evaluation (if it doesn't fail then it's
    a compiler bug and not the library's problem). Disabling this check
    during constant evaluation shouldn't do any harm.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/109517
            PR libstdc++/109976
            * include/debug/helper_functions.h (__valid_range_aux): Treat
            all input iterator ranges as valid during constant evaluation.

Diff:
---
 libstdc++-v3/include/debug/helper_functions.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h
index d686a29e8ee9..8d6a5fb41fb4 100644
--- a/libstdc++-v3/include/debug/helper_functions.h
+++ b/libstdc++-v3/include/debug/helper_functions.h
@@ -168,6 +168,11 @@ namespace __gnu_debug
     __valid_range_aux(_InputIterator __first, _InputIterator __last,
 		      std::input_iterator_tag)
     {
+      // FIXME: The checks for singular iterators fail during constant eval
+      // due to PR c++/85944. e.g. PR libstdc++/109517 and PR libstdc++/109976.
+      if (std::__is_constant_evaluated())
+	return true;
+
       return __first == __last
 	|| (!__gnu_debug::__check_singular(__first)
 	      && !__gnu_debug::__check_singular(__last));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-11 21:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-11 21:55 [gcc r15-6126] libstdc++: Disable __gnu_debug::__is_singular(T*) in constexpr [PR109517] Jonathan Wakely

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