https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82042
Bug ID: 82042 Summary: signed integer overflow in ao_ref_init_from_ptr_and_size Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- When compiled with today's top of trunk (GCC 8.0) configured for x86_64-linux --with-build-config=bootstrap-ubsan the following test case triggers a runtime error in the ao_ref_init_from_ptr_and_size() function in tree-ssa-alias.c (besides a number of others). $ cat t.c && gcc -O2 -S -Wall -ftracer t.c char *p; extern char a[]; void f (int i) { __SIZE_TYPE__ idx = __SIZE_MAX__ / 2 - 1; p = __builtin_stpcpy (&a[idx], i ? "123" : "12345"); } /src/gcc/git/gcc/tree-ssa-alias.c:704:30: runtime error: signed integer overflow: 9223372036854775806 * 8 cannot be represented in type 'long int' /src/gcc/git/gcc/alias.c:2583:21: runtime error: signed integer overflow: -9223372036854775806 - 9223372036854775806 cannot be represented in type 'long int' /src/gcc/git/gcc/cse.c:2195:10: runtime error: signed integer overflow: -9223372036854775805 - 9223372036854775806 cannot be represented in type 'long int' /src/gcc/git/gcc/dse.c:932:38: runtime error: signed integer overflow: 9223372036854775806 + 4 cannot be represented in type 'long int' /src/gcc/git/gcc/dse.c:1539:28: runtime error: signed integer overflow: 4 + 9223372036854775806 cannot be represented in type 'long int'