public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/108014] New: Incorrect line number in UBSAN's report
@ 2022-12-07 21:29 shaohua.li at inf dot ethz.ch
2022-12-07 21:31 ` [Bug sanitizer/108014] " pinskia at gcc dot gnu.org
2022-12-07 21:42 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2022-12-07 21:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108014
Bug ID: 108014
Summary: Incorrect line number in UBSAN's report
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, GCC's UBsan at -O1 and above produces incorrect line
number in the final report.
Compiler explorer: https://godbolt.org/z/jvvdrfPdo
% cat -n a.c
1 int a, b;
2 char c[5];
3 int d[1];
4 static int g() {
5 long e;
6 b = __INT_MAX__;
7 for (int f = 0; f < sizeof(c); f++)
8 e = b + 1;
9 return 0;
10 }
11 int main() {
12 for (b = 0;b<1; b++) {
13 d[a];
14 g();
15 }
16 }
%
% gcc-tk -O0 -fsanitize=undefined -fno-sanitize-recover=all a.c && ./a.out
a.c:8:11: runtime error: signed integer overflow: 2147483647 + 1 cannot be
represented in type 'int'
% gcc-tk -O1 -fsanitize=undefined -fno-sanitize-recover=all a.c && ./a.out
a.c:12:20: runtime error: signed integer overflow: 2147483647 + 1 cannot be
represented in type 'int'
%
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug sanitizer/108014] Incorrect line number in UBSAN's report
2022-12-07 21:29 [Bug sanitizer/108014] New: Incorrect line number in UBSAN's report shaohua.li at inf dot ethz.ch
@ 2022-12-07 21:31 ` pinskia at gcc dot gnu.org
2022-12-07 21:42 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 21:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108014
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54040
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54040&action=edit
testcase without line #
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug sanitizer/108014] Incorrect line number in UBSAN's report
2022-12-07 21:29 [Bug sanitizer/108014] New: Incorrect line number in UBSAN's report shaohua.li at inf dot ethz.ch
2022-12-07 21:31 ` [Bug sanitizer/108014] " pinskia at gcc dot gnu.org
@ 2022-12-07 21:42 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 21:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108014
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't know if this is a bug really.
The statement on line 9 (`e = b + 1;`) gets removed and therefor there was no
undefined behavior that happens at all.
Either DSE or CDDCE does the removal (depending on if you use -Og or -O1):
Deleted trivially dead stmt: [/app/example.cpp:9:7] e_9 = (long int) _2;
Deleted trivially dead stmt: [/app/example.cpp:9:11] _2 = .UBSAN_CHECK_ADD
(2147483647, 1);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-07 21:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 21:29 [Bug sanitizer/108014] New: Incorrect line number in UBSAN's report shaohua.li at inf dot ethz.ch
2022-12-07 21:31 ` [Bug sanitizer/108014] " pinskia at gcc dot gnu.org
2022-12-07 21:42 ` 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).