[Bug c/85563] New: -Wmaybe-uninitialized false alarm regression with __builtin_unreachable and GCC 8
eggert at cs dot ucla.edu
gcc-bugzilla@gcc.gnu.org
Sat Apr 28 20:02:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85563
Bug ID: 85563
Summary: -Wmaybe-uninitialized false alarm regression with
__builtin_unreachable and GCC 8
Product: gcc
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eggert at cs dot ucla.edu
Target Milestone: ---
When compiling Emacs with gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20) x86-64
I noticed a regression compared to previous GCC versions, a regression that
causes a false alarm. Briefly, Emacs uses a statement like this:
((CONSP (Vframe_list)) ? (void) 0 : __builtin_unreachable ());
to tell Emacs that Vframe_list is a cons (CONSP is inline and side effect
free), and then follows this with a loop:
for ((tail) = Vframe_list;
(CONSP (tail) && (frame1 = XCAR (tail), 1));
tail = XCDR (tail))
{ loop body }
which obviously must initialize frame1. In a later use of frame1, though, GCC
8.0.1 incorrectly complains:
f.i: In function ‘delete_frame’:
f.i:69688:7: warning: ‘frame1’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
do_switch_frame (frame1, 0, 1, builtin_lisp_symbol (0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where GCC 7 and earlier do not complain. To reproduce the problem, use the
command:
gcc -O2 -S -Wmaybe-uninitialized f.i
on the attached file f.i. Although strictly speaking this isn't a bug since the
"may be used uninitialized" is deliberately wishy-washy, still, it's an
annoyance that I'll have to fiddle with Emacs source to pacify the misguided
compiler here.
More information about the Gcc-bugs
mailing list