https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79650
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another testcase that ICEs:
template<__INTPTR_TYPE__> struct A {};
void
foo ()
{
static int a, b;
A<4 + (__INTPTR_TYPE__)&a> c;
}
In the end, the question is what is a constant expression. Expressions like
4 + (__INTPTR_TYPE__)&var
or
(__INTPTR_TYPE__)&&lab1 - (__INTPTR_TYPE__)&&lab2
are valid assembly time constants, which means we can safely put them into say
.rodata variable initializers. Which is why initializer_constant_valid_p
returns non-NULL for them, and that is what reduced_constant_expression_p
calls.
On the other side, I bet at least for template integral parameters that isn't
what we care about, we really need something that folds into an integer.