public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/109107] New: UBsan since GCC-8 misses an integer-overflow
@ 2023-03-12 13:54 shaohua.li at inf dot ethz.ch
  2023-03-13 13:58 ` [Bug sanitizer/109107] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-03-12 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109107
           Summary: UBsan since GCC-8 misses an integer-overflow
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                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: ---

For the following code, UBsan since GCC-8 at -O1 and above misses the integer
overflow. GCC-7 can detect it at all opt levels.

Clang can detect it at all opt levels.

Compiler explorer: https://godbolt.org/z/Pez4jd5aj

% cat a.c
int a = -2147468918, c;
const long b = 676540;
int main() { 
    c = 1 + a - (short)b; 
    return c;
}
%
% gcc-tk -O1 -fsanitize=undefined a.c &&./a.out
%
% gcc-7 -O1 -fsanitize=undefined a.c &&./a.out
/a.c:4:15: runtime error: signed integer overflow: -2147468918 - 21179 cannot
be represented in type 'int'
%

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

end of thread, other threads:[~2024-02-01  9:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12 13:54 [Bug sanitizer/109107] New: UBsan since GCC-8 misses an integer-overflow shaohua.li at inf dot ethz.ch
2023-03-13 13:58 ` [Bug sanitizer/109107] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
2023-03-13 14:37 ` mpolacek at gcc dot gnu.org
2023-03-14 13:51 ` mpolacek at gcc dot gnu.org
2023-04-04 13:14 ` cvs-commit at gcc dot gnu.org
2023-04-04 13:14 ` mpolacek at gcc dot gnu.org
2024-02-01  9:55 ` pinskia 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).