https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80100
Bug ID: 80100 Summary: simplify-rtx.c sanitizer detects undefined behaviour with optimization Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: zeccav at gmail dot com Target Milestone: --- //gcc 7.0.1 trunk 246252 undefined behaviour with optimization //-O0 and -Og ok, higher levels get undefined long int f2 (long int k) { return 2L | ((k - 1L) >> ((int) sizeof (long int) * __CHAR_BIT__ - 1)); } //../../gcc-7-246252/gcc/simplify-rtx.c:2743:49: runtime error: left shift of 2 by 63 places cannot be represented in type 'long int' //simplify-rtx.c:2743 is "HOST_WIDE_INT mask = INTVAL (trueop1) << count;