[Bug c++/103297] GCC cannot detect out of bounds in constexpr context.
unlvsur at live dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 17 11:33:39 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103297
--- Comment #1 from cqwrteur <unlvsur at live dot com> ---
Another issue
#include<string_view>
#include<string>
#include<cassert>
inline constexpr std::string_view lifetime_detector(std::string const& str)
noexcept
{
return str;
}
inline constexpr bool test2(std::string_view vw2) noexcept
{
bool res{true};
for(auto e : vw2)
res|=e;
return true;
}
inline constexpr bool test() noexcept
{
std::string_view vw{lifetime_detector("abcde12124")};
return test2(vw);
}
static_assert(test());
int main()
{
assert(test());
}
This does not get detected at neither compile nor runtime???
More information about the Gcc-bugs
mailing list