From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABA423858D3C; Fri, 26 May 2023 03:25:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABA423858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685071553; bh=veddjXVCweb84w3rj3C1WpqKXmfs13Jn6/fTHbdk76s=; h=From:To:Subject:Date:From; b=qYh7Vbpa+y5giuwgv/SCARKd3KplK+/+khDgiNFYJ304RyMt9n5/U0FQkQb4AvGSg 1Yb9fFsLfniT/P7TzNDNFYqdPziQz7WW1Ql9+q0eXiEOqUMuh2g3rv+EYqjlJQmFlD vNX70l6iRT0itCLW6SqFKkMVcRNQXXjQ541rTVL0= From: "ed at catmur dot uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109976] New: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG Date: Fri, 26 May 2023 03:25:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ed at catmur dot uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109976 Bug ID: 109976 Summary: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- #define _GLIBCXX_DEBUG #include #include constexpr bool f(std::string const& l, std::string const& r) { return std::equal(l.data(), l.data() + l.size(), r.data(), r.data() + r.size()); } constexpr bool b =3D f("aa", "aa"); In file included from c++/14.0.0/debug/stl_iterator.h:32, from c++/14.0.0/bits/stl_iterator.h:3004, from c++/14.0.0/bits/stl_algobase.h:67, from c++/14.0.0/algorithm:60, from :2: :7:21: in 'constexpr' expansion of 'f(std::__cxx11::basic_string(((const char*)"aa"), std::allocator()), std::__cxx11::basic_string(((const char*)"aa= "), std::allocator()))' :5:22: in 'constexpr' expansion of 'std::equal((& l)->std::__cxx11::basic_string::data(), ((& l)->std::__cxx11::basic_string::data() + ((sizetype)(& l)->std::__cxx11::basic_string::size())), (& r)->std::__cxx11::basic_string::data(), ((& r)->std::__cxx11::basic_string::data() + ((sizetype)(& r)->std::__cxx11::basic_string::size())))' c++/14.0.0/bits/stl_algobase.h:1679:7: in 'constexpr' expansion of '__gnu_debug::__valid_range(__first1, __last1)' c++/14.0.0/debug/helper_functions.h:257:31: in 'constexpr' expansion of '__gnu_debug::__valid_range_aux(__first, __last, (_Integral(), _Integral()))' c++/14.0.0/debug/helper_functions.h:189:31: in 'constexpr' expansion of '__gnu_debug::__valid_range_aux(__first, __last, (std::__iterator_category(__first), std::iterator_traits::iterator_category()))' c++/14.0.0/debug/helper_functions.h:176:19: in 'constexpr' expansion of '__gnu_debug::__valid_range_aux(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))' c++/14.0.0/debug/helper_functions.h:136:20: error: '(((const char*)(&.std::__cxx11::basic_string::.std::__cx= x11::basic_string::::_M_local_buf)) =3D=3D 0)' is not a constant expression 136 | { return __ptr =3D=3D 0; } | ~~~~~~^~~~ This appears to be caused by bug 109975, but I'm filing separately since it= =20 may be possible to fix in library. The code is accepted if _GLIBCXX_DEBUG is not defined, since __gnu_debug::__valid_range is not checked.=