[Bug c++/105821] New: ICE for illegal constexpr-if
fiesh at zefix dot tv
gcc-bugzilla@gcc.gnu.org
Thu Jun 2 11:18:51 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105821
Bug ID: 105821
Summary: ICE for illegal constexpr-if
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fiesh at zefix dot tv
Target Milestone: ---
The following code leads to resource exhaustion:
namespace a {};
template <int g, unsigned h> int r() {
if constexpr (a) {
return r<g, h / 2>();
} else {
return r<(g + h) / 2, h>();
}
}
template <int f, unsigned g> int count() {
return r<0, g>() + count<f, g * 2>();
}
struct q {
const int p = count<0, 1>();
};
Tested with 7 through 12. Changing "if constexpr(a)" to say "if
constexpr(a::b)" exhibits the same behavior.
(It also seems to crash clang-14, but not clang-13 and older. It seems they do
crash with "a::b" instead of "a" though.)
More information about the Gcc-bugs
mailing list