https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81088
Bug ID: 81088 Summary: UBSAN: false positive as a result of reassosiation Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: babokin at gmail dot com CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- gcc rev249171. > cat f.cpp short s = 2; short y = 1; int i; int main() { i = -(s + int(~unsigned(0 / y))) + 0x7fffffff; return 0; } > g++ -fsanitize=undefined -O0 f.cpp -o out > ./out f.cpp:5:36: runtime error: signed integer overflow: -2 + -2147483648 cannot be represented in type 'int'