This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/85777] New: [7/8 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear
- From: "vincent-gcc at vinc17 dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 May 2018 14:42:07 +0000
- Subject: [Bug sanitizer/85777] New: [7/8 Regression] -fsanitize=undefined makes a -Wmaybe-uninitialized warning disappear
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85777
Bug ID: 85777
Summary: [7/8 Regression] -fsanitize=undefined makes a
-Wmaybe-uninitialized warning disappear
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent-gcc at vinc17 dot net
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: ---
On some C files, adding the -fsanitize=undefined option makes a
-Wmaybe-uninitialized warning disappear.
In the past, I reported PR81981, which was fixed for the provided testcase. But
this was just a simplified testcase of tests/turandom.c in MPFR revision 11663,
and the problem still occurs for this revision of MPFR.
I've used creduce with the following test under Debian/unstable in order to
obtain another simplified testcase:
------------------------------------------------------------
#!/bin/sh
cmd="gcc-snapshot -Werror=uninitialized -Werror=maybe-uninitialized -O2 -c
file.c"
$cmd -fsanitize=undefined && ! $cmd
------------------------------------------------------------
The obtained file.c file is:
------------------------------------------------------------
enum { a, b } typedef c;
d;
e() {
c f[2];
int g = 0;
if (d)
g++;
if (d == b)
f[g++] = 2;
f[0] || g &&h();
}
------------------------------------------------------------
I get the "‘f[0]’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]" error with:
* gcc-6 -Werror=maybe-uninitialized -O2 -c file.c
* gcc-6 -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined
* gcc-7 -Werror=maybe-uninitialized -O2 -c file.c
* gcc-8 -Werror=maybe-uninitialized -O2 -c file.c
* gcc-snapshot -Werror=maybe-uninitialized -O2 -c file.c
but not with:
* gcc-7 -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined
* gcc-8 -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined
* gcc-snapshot -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined
FYI, currently under Debian/unstable:
* gcc-6 (Debian 6.4.0-17) 6.4.0 20180424
* gcc-7 (Debian 7.3.0-19) 7.3.0
* gcc-8 (Debian 8.1.0-3) 8.1.0
* gcc (Debian 20180512-1) 9.0.0 20180512 (experimental) [trunk revision
260194]