https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103046
Bug ID: 103046 Summary: Incorrect debug info for uint128 bit shift in gcc 11.2 Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: liyd2021 at gmail dot com Target Milestone: --- Affected versions: gcc 11.2.0 with gdb (Ubuntu 20.04.2) gcc11.2 generates wrong debug when left shift uint128 value for more than 64 bits. The debug info shows variable `a` has a const value `0xff00...` while the actual value of `a` is `0x0100...` This bug cannot be reproduced in gcc 10 or 9. (terminal) $ cat a.c && gcc -g -Og a.c typedef unsigned __int128 U; __attribute__((noipa)) void foo(U x) {} int main() { U a = (U) 1 << 120; foo(a); } -------------------- (terminal) $ cat run.gdb b 7 b foo r p/x a c p/x x -------------------- (terminal) $ gdb -x run.gdb a.out Breakpoint 1 at 0x40116e: file a.c, line 7. Breakpoint 2 at 0x401169: file a.c, line 3. Breakpoint 1, main () at a.c:7 7 foo(a); $1 = 0xff000000000000000000000000000000 <- **BUG**: wrong value Breakpoint 2, foo (x=1329227995784915872903807060280344576) at a.c:3 3 __attribute__((noipa)) void foo(U x) {} $2 = 0x1000000000000000000000000000000 <- correct value -------------------- debug info and assembly: <2><61>: Abbrev Number: 5 (DW_TAG_variable) <62> DW_AT_name : a <64> DW_AT_decl_file : 1 <65> DW_AT_decl_line : 6 <66> DW_AT_decl_column : 7 <67> DW_AT_type : <0x2e> <6b> DW_AT_const_value : 0xff000000000000000000000000000000