public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109090] New: UBSan signed integer overflow check missing.
@ 2023-03-10 15:16 cbossut21 at gatech dot edu
  2023-03-10 15:20 ` [Bug c/109090] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: cbossut21 at gatech dot edu @ 2023-03-10 15:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

            Bug ID: 109090
           Summary: UBSan signed integer overflow check missing.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cbossut21 at gatech dot edu
  Target Milestone: ---

$ cat test.c
int printf(const char *, ...);
int a = 3181903460;
int *b, *c = &a;
int **d = &b;
void main(void) {
  *d = c;
  *b = 0 > *c + *c;
  printf("checksum = %X\n", a);
}


UBSan doesn't emit any runtime error messages reporting overflow for the most
recent version of gcc. However in gcc-7 UBSan reports overflow, and the using
the -fwrapv flag produces different output.


$ gcc-7 -O3 -fsanitize=undefined test.c ; ./a.out
test.c:7:15: runtime error: signed integer overflow: -1113063836 * 2 cannot be
represented in type 'int'
checksum = 0

$ gcc-trunk -fwrapv -O3 -fsanitize=undefined test.c ; ./a.out
checksum = 0

$ gcc-trunk -O3 -fsanitize=undefined test.c ; ./a.out
checksum = 1

$ gcc-trunk -fsanitize=undefined test.c ; ./a.out
checksum = 1

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

* [Bug c/109090] [10/11/12/13 Regression] UBSan signed integer overflow check missing.
  2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
@ 2023-03-10 15:20 ` mpolacek at gcc dot gnu.org
  2023-03-10 15:25 ` [Bug sanitizer/109090] " mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-10 15:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |10.5
     Ever confirmed|0                           |1
            Summary|UBSan signed integer        |[10/11/12/13 Regression]
                   |overflow check missing.     |UBSan signed integer
                   |                            |overflow check missing.
   Last reconfirmed|                            |2023-03-10
           Priority|P3                          |P2

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

int a = -1113063836;
int *b, *c = &a;
int **d = &b;
int main(void) {
  *d = c;
  *b = 0 > *c + *c;
  __builtin_printf("checksum = %X\n", a);
}

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

* [Bug sanitizer/109090] [10/11/12/13 Regression] UBSan signed integer overflow check missing.
  2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
  2023-03-10 15:20 ` [Bug c/109090] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
@ 2023-03-10 15:25 ` mpolacek at gcc dot gnu.org
  2023-03-10 15:26 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-10 15:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r8-343-g2bf54d93f15921 it seems:

commit 2bf54d93f159210d0c05a07c655eb847c069365c
Author: Richard Biener <rguenther@suse.de>
Date:   Tue May 2 12:43:47 2017 +0000

    common.opt (fstrict-overflow): Alias negative to fwrapv.

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

* [Bug sanitizer/109090] [10/11/12/13 Regression] UBSan signed integer overflow check missing.
  2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
  2023-03-10 15:20 ` [Bug c/109090] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
  2023-03-10 15:25 ` [Bug sanitizer/109090] " mpolacek at gcc dot gnu.org
@ 2023-03-10 15:26 ` marxin at gcc dot gnu.org
  2023-03-10 15:30 ` mpolacek at gcc dot gnu.org
  2023-07-07 10:45 ` [Bug sanitizer/109090] [11/12/13/14 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-03-10 15:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
A dup of PR108995?

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

* [Bug sanitizer/109090] [10/11/12/13 Regression] UBSan signed integer overflow check missing.
  2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
                   ` (2 preceding siblings ...)
  2023-03-10 15:26 ` marxin at gcc dot gnu.org
@ 2023-03-10 15:30 ` mpolacek at gcc dot gnu.org
  2023-07-07 10:45 ` [Bug sanitizer/109090] [11/12/13/14 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-10 15:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Dunno, this doesn't seem to be fixed by the patch in PR108995.

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

* [Bug sanitizer/109090] [11/12/13/14 Regression] UBSan signed integer overflow check missing.
  2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
                   ` (3 preceding siblings ...)
  2023-03-10 15:30 ` mpolacek at gcc dot gnu.org
@ 2023-07-07 10:45 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109090

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 15:16 [Bug c/109090] New: UBSan signed integer overflow check missing cbossut21 at gatech dot edu
2023-03-10 15:20 ` [Bug c/109090] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
2023-03-10 15:25 ` [Bug sanitizer/109090] " mpolacek at gcc dot gnu.org
2023-03-10 15:26 ` marxin at gcc dot gnu.org
2023-03-10 15:30 ` mpolacek at gcc dot gnu.org
2023-07-07 10:45 ` [Bug sanitizer/109090] [11/12/13/14 " rguenth 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).