public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/108885] New: Missing sanitization checks for optimized integer
@ 2023-02-22 13:50 cbossut21 at gatech dot edu
  2023-02-22 13:53 ` [Bug sanitizer/108885] " jakub at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: cbossut21 at gatech dot edu @ 2023-02-22 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108885
           Summary: Missing sanitization checks for optimized integer
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cbossut21 at gatech dot edu
                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: ---

I noticed the following behavior for the following code in test.c:

=====
#include "stdio.h"
int a = 6;
int main() { 
  int c = a * 936722028; 
  printf("%d\n", a);
}
=====

$ gcc-trunk -fsanitize=signed-integer-overflow -O3 -msse4.2  test.c -o test

$ ./test
6

$ gcc-trunk -v
gcc version 13.0.1 20230218 (experimental) [master r13-6132-g32b5875c911] (GCC) 

There are no sanitization checks inserted in this case, despite overflow
occurring on the first line of main. It seems like the check is optimized out.
However, the same code produces a signed integer overflow error at runtime when
compiled with clang using the same flags. 

Is this expected behavior for GCC? Thanks!

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

* [Bug sanitizer/108885] Missing sanitization checks for optimized integer
  2023-02-22 13:50 [Bug sanitizer/108885] New: Missing sanitization checks for optimized integer cbossut21 at gatech dot edu
@ 2023-02-22 13:53 ` jakub at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-22 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The signed integer overflow is in dead code and so is dead code eliminated.
It would be reported with -O0 -fsanitize=undefined

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

end of thread, other threads:[~2023-02-22 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 13:50 [Bug sanitizer/108885] New: Missing sanitization checks for optimized integer cbossut21 at gatech dot edu
2023-02-22 13:53 ` [Bug sanitizer/108885] " 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).