public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109976] New: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG
@ 2023-05-26 3:25 ed at catmur dot uk
2023-05-26 3:28 ` [Bug libstdc++/109976] " pinskia at gcc dot gnu.org
2023-05-26 8:20 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: ed at catmur dot uk @ 2023-05-26 3:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109976
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 <algorithm>
#include <string>
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 = 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 <source>:2:
<source>:7:21: in 'constexpr' expansion of
'f(std::__cxx11::basic_string<char>(((const char*)"aa"),
std::allocator<char>()), std::__cxx11::basic_string<char>(((const char*)"aa"),
std::allocator<char>()))'
<source>:5:22: in 'constexpr' expansion of 'std::equal<const char*, const
char*>((& l)->std::__cxx11::basic_string<char>::data(), ((&
l)->std::__cxx11::basic_string<char>::data() + ((sizetype)(&
l)->std::__cxx11::basic_string<char>::size())), (&
r)->std::__cxx11::basic_string<char>::data(), ((&
r)->std::__cxx11::basic_string<char>::data() + ((sizetype)(&
r)->std::__cxx11::basic_string<char>::size())))'
c++/14.0.0/bits/stl_algobase.h:1679:7: in 'constexpr' expansion of
'__gnu_debug::__valid_range<const char*>(__first1, __last1)'
c++/14.0.0/debug/helper_functions.h:257:31: in 'constexpr' expansion of
'__gnu_debug::__valid_range_aux<const char*>(__first, __last, (_Integral(),
_Integral()))'
c++/14.0.0/debug/helper_functions.h:189:31: in 'constexpr' expansion of
'__gnu_debug::__valid_range_aux<const char*>(__first, __last,
(std::__iterator_category<const char*>(__first), std::iterator_traits<const
char*>::iterator_category()))'
c++/14.0.0/debug/helper_functions.h:176:19: in 'constexpr' expansion of
'__gnu_debug::__valid_range_aux<const char*>(__first, __last,
(std::input_iterator_tag(), std::input_iterator_tag()))'
c++/14.0.0/debug/helper_functions.h:136:20: error: '(((const
char*)(&<anonymous>.std::__cxx11::basic_string<char>::<anonymous>.std::__cxx11::basic_string<char>::<unnamed
union>::_M_local_buf)) == 0)' is not a constant expression
136 | { return __ptr == 0; }
| ~~~~~~^~~~
This appears to be caused by bug 109975, but I'm filing separately since it
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/109976] error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG
2023-05-26 3:25 [Bug libstdc++/109976] New: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG ed at catmur dot uk
@ 2023-05-26 3:28 ` pinskia at gcc dot gnu.org
2023-05-26 8:20 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-26 3:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109976
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=106212
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 85944 (via PR 106212).
*** This bug has been marked as a duplicate of bug 85944 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/109976] error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG
2023-05-26 3:25 [Bug libstdc++/109976] New: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG ed at catmur dot uk
2023-05-26 3:28 ` [Bug libstdc++/109976] " pinskia at gcc dot gnu.org
@ 2023-05-26 8:20 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-26 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109976
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Ed Catmur from comment #0)
> This appears to be caused by bug 109975, but I'm filing separately since it
> may be possible to fix in library.
Maybe we can skip some of the debug checks during constant evaluation, relying
on the compiler to diagnose them anyway.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-26 8:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26 3:25 [Bug libstdc++/109976] New: error: is not a constant expression in std::equal() with _GLIBCXX_DEBUG ed at catmur dot uk
2023-05-26 3:28 ` [Bug libstdc++/109976] " pinskia at gcc dot gnu.org
2023-05-26 8:20 ` 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).