[Bug ipa/111922] [11/12/13/14 Regression] ICE in cp with -O2 -fno-tree-fre
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 22 14:27:14 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111922
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com,
| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly cleaned up:
void f2 (void);
void f4 (int, int, int);
struct A { int a; };
struct B { struct A *b; int c; } v;
static int
f1 (x, y)
struct C *x;
struct A *y;
{
(v.c = v.b->a) || (v.c = v.b->a);
f2 ();
}
static void
f3 (int x, int y)
{
int b = f1 (0, ~x);
f4 (0, 0, v.c);
}
void
f5 (void)
{
f3 (0, 0);
}
The problem is in the f1 call, given it uses the K&R definition style and the
caller invokes UB by using incompatible types (int vs. pointers), I think
IPA-VRP should punt somewhere on the type mismatch.
I think
Value_Range vr (operand_type);
if (TREE_CODE_CLASS (operation) == tcc_unary)
ipa_vr_operation_and_type_effects (vr,
src_lats->m_value_range.m_vr,
operation, param_type,
operand_type);
should be avoided if param_type is not a compatible type to operand_type,
unless operation is some cast operation (NOP_EXPR, CONVERT_EXPR, dunno if the
float to integral or vice versa ops as well but vrp probably doesn't handle
that yet).
In the above case, param_type is struct A *, i.e. pointer, while operand_type
is int.
More information about the Gcc-bugs
mailing list