[Bug c++/104803] if consteval error from branch that isn't evaluated anyway

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Mar 6 06:28:37 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104803

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang does a better job of explaining though:
<source>:6:17: error: call to consteval function '(anonymous
class)::operator()' is not a constant expression
            if (p(i)) { // <== line 5
                ^
<source>:19:15: note: in instantiation of function template specialization
'none_of<const int (&)[3], (lambda at <source>:20:5)>' requested here
static_assert(none_of(vals,
              ^
<source>:6:19: note: read of non-const variable 'i' is not allowed in a
constant expression
            if (p(i)) { // <== line 5
                  ^
<source>:4:14: note: declared here
    for (int i : r) {
             ^
<source>:10:17: error: call to consteval function '(anonymous
class)::operator()' is not a constant expression
            if (p(i)) { // <== line 9
                ^
<source>:10:19: note: read of non-const variable 'i' is not allowed in a
constant expression
            if (p(i)) { // <== line 9
                  ^
<source>:4:14: note: declared here
    for (int i : r) {
             ^


More information about the Gcc-bugs mailing list