public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/103046] New: Incorrect debug info for uint128 bit shift in gcc 11.2
@ 2021-11-02 14:11 liyd2021 at gmail dot com
  2021-11-02 15:46 ` [Bug debug/103046] [11/12 Regression] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: liyd2021 at gmail dot com @ 2021-11-02 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-29  9:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 14:11 [Bug debug/103046] New: Incorrect debug info for uint128 bit shift in gcc 11.2 liyd2021 at gmail dot com
2021-11-02 15:46 ` [Bug debug/103046] [11/12 Regression] " jakub at gcc dot gnu.org
2021-11-05  9:23 ` cvs-commit at gcc dot gnu.org
2021-11-05 13:38 ` [Bug debug/103046] [11 " rguenth at gcc dot gnu.org
2021-11-29  8:49 ` cvs-commit at gcc dot gnu.org
2021-11-29  9:08 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).