public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada
@ 2021-03-04 5:49 zeccav at gmail dot com
2021-03-04 7:52 ` [Bug rtl-optimization/99376] " marxin at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: zeccav at gmail dot com @ 2021-03-04 5:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
Bug ID: 99376
Summary: Sanitizer detects undefined behaviour in rtlanal.c
compiling ada
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zeccav at gmail dot com
Target Milestone: ---
Needs option -O2
-- /home/vitti/gcc-150221-full-undefined/gcc/xgcc -S
-B/home/vitti/gcc-150221-full-undefined/gcc/
-I/home/vitti/gcc-150221-full-undefined/gcc/testsuite/ada/acats/support
~/f95/ada1.adb -O2
-- ../../gcc-150221/gcc/rtlanal.c:5060:35: runtime error: shift exponent 126 is
too large for 64-bit type 'long unsigned int'
-- rtlanal.c:5060 "nonzero &= ~((HOST_WIDE_INT_1U << result_low) - 1);"
WITH REPORT; USE REPORT;
PROCEDURE ada1 IS
F : LONG_INTEGER;
FUNCTION IDENT_LONG(A : LONG_INTEGER) RETURN LONG_INTEGER IS
BEGIN
IF EQUAL (3, 3) THEN
RETURN A;
ELSE
RETURN 0;
END IF;
END IDENT_LONG;
FUNCTION LONG_OK (X : LONG_INTEGER) RETURN BOOLEAN IS
BEGIN
return true;
END;
BEGIN
F := IDENT_LONG(LONG_INTEGER'FIRST);
BEGIN
IF LONG_OK (F*F) THEN
return ;
END IF;
END;
END ada1;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c compiling ada
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
@ 2021-03-04 7:52 ` marxin at gcc dot gnu.org
2021-03-04 9:50 ` [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c ebotcazou at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-04 7:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Blocks| |63426
Last reconfirmed| |2021-03-04
CC| |bonzini at gnu dot org,
| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
2021-03-04 7:52 ` [Bug rtl-optimization/99376] " marxin at gcc dot gnu.org
@ 2021-03-04 9:50 ` ebotcazou at gcc dot gnu.org
2021-03-04 9:57 ` ebotcazou at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-03-04 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Sanitizer detects undefined |Sanitizer detects undefined
|behaviour in rtlanal.c |behaviour in rtlanal.c
|compiling ada |
--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Nothing specific to Ada, it's
(mult:DI (reg:DI 87 [ _9 ])
(reg:DI 87 [ _9 ]))
with (reg:DI 87) equal to LONG_MIN so low0 = low1 = 63.
Clearly a pair of tests against HOST_BITS_PER_WIDE_INT is missing in:
if (result_width < mode_width)
nonzero &= (HOST_WIDE_INT_1U << result_width) - 1;
if (result_low > 0)
nonzero &= ~((HOST_WIDE_INT_1U << result_low) - 1);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
2021-03-04 7:52 ` [Bug rtl-optimization/99376] " marxin at gcc dot gnu.org
2021-03-04 9:50 ` [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c ebotcazou at gcc dot gnu.org
@ 2021-03-04 9:57 ` ebotcazou at gcc dot gnu.org
2021-03-04 10:04 ` [Bug rtl-optimization/99376] sanitizer " ebotcazou at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-03-04 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ebotcazou at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] sanitizer detects undefined behaviour in rtlanal.c
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
` (2 preceding siblings ...)
2021-03-04 9:57 ` ebotcazou at gcc dot gnu.org
@ 2021-03-04 10:04 ` ebotcazou at gcc dot gnu.org
2021-03-05 11:47 ` cvs-commit at gcc dot gnu.org
2021-03-05 11:56 ` ebotcazou at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-03-04 10:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Clearly a pair of tests against HOST_BITS_PER_WIDE_INT is missing in:
>
> if (result_width < mode_width)
> nonzero &= (HOST_WIDE_INT_1U << result_width) - 1;
>
> if (result_low > 0)
> nonzero &= ~((HOST_WIDE_INT_1U << result_low) - 1);
Actually only for result_low, as mode_width <= HOST_BITS_PER_WIDE_INT.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] sanitizer detects undefined behaviour in rtlanal.c
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
` (3 preceding siblings ...)
2021-03-04 10:04 ` [Bug rtl-optimization/99376] sanitizer " ebotcazou at gcc dot gnu.org
@ 2021-03-05 11:47 ` cvs-commit at gcc dot gnu.org
2021-03-05 11:56 ` ebotcazou at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-05 11:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:
https://gcc.gnu.org/g:28354bc22bd66648891a875ee08ca2b27debf2a2
commit r11-7521-g28354bc22bd66648891a875ee08ca2b27debf2a2
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Fri Mar 5 12:38:49 2021 +0100
Fix undefined behavior spotted by the sanitizer
gcc/
PR rtl-optimization/99376
* rtlanal.c (nonzero_bits1) <arithmetic operators>: If the number
of low-order zero bits is too large, set the result to 0 directly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug rtl-optimization/99376] sanitizer detects undefined behaviour in rtlanal.c
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
` (4 preceding siblings ...)
2021-03-05 11:47 ` cvs-commit at gcc dot gnu.org
@ 2021-03-05 11:56 ` ebotcazou at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-03-05 11:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99376
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |11.0
--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-03-05 11:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 5:49 [Bug rtl-optimization/99376] New: Sanitizer detects undefined behaviour in rtlanal.c compiling ada zeccav at gmail dot com
2021-03-04 7:52 ` [Bug rtl-optimization/99376] " marxin at gcc dot gnu.org
2021-03-04 9:50 ` [Bug rtl-optimization/99376] Sanitizer detects undefined behaviour in rtlanal.c ebotcazou at gcc dot gnu.org
2021-03-04 9:57 ` ebotcazou at gcc dot gnu.org
2021-03-04 10:04 ` [Bug rtl-optimization/99376] sanitizer " ebotcazou at gcc dot gnu.org
2021-03-05 11:47 ` cvs-commit at gcc dot gnu.org
2021-03-05 11:56 ` ebotcazou 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).