https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97855
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
CC| |dmalcolm at gcc dot gnu.org
Last reconfirmed| |2021-02-26
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The issue seems to be that in diagnostic_report_diagnostic () we do
1244 pp_format (context->printer, &diagnostic->message);
1245 (*diagnostic_starter (context)) (context, diagnostic);
where the first call ends up with the %qD part of "%qD may be used
uninitialized in this function" still in the pretty-printers buffer which then
the
diagnostic_starter will use without resetting it.
For the specific message the expression is formatted via default_tree_printer
and dump_generic_node (we have sth usable in DECL_DEBUG_EXPR).
The following seems to fix it but I'm not sure what the actual mistake in
using the diagnostic provided pretty-printer is. The dump_generic_node
doesn't cause any flushing.
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 95b8ef30070..f124e627aad 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -300,7 +300,11 @@ default_tree_printer (pretty_printer *pp, text_info *text,
const char *spec,
pp_string (pp, n);
}
else
- dump_generic_node (pp, t, 0, TDF_SLIM, 0);
+ {
+ pretty_printer buffer;
+ dump_generic_node (&buffer, t, 0, TDF_SLIM, 0);
+ pp_string (pp, pp_formatted_text (&buffer));
+ }
return true;
}
This then issues
/home/rguenther/src/trunk/gcc/calls.c: In function 'expand_call':
/home/rguenther/src/trunk/gcc/dojump.c:118:28: warning: 'MEM[(struct poly_int
*)&save].D.6750.coeffs[0]' may be used uninitialized in this function
[-Wmaybe-uninitialized]
118 | pending_stack_adjust = save->x_pending_stack_adjust;
| ^
/home/rguenther/src/trunk/gcc/calls.c:4150:34: note: 'MEM[(struct poly_int
*)&save].D.6750.coeffs[0]' was declared here
4150 | saved_pending_stack_adjust save;
| ^
/home/rguenther/src/trunk/gcc/dojump.c:119:27: warning: 'MEM[(struct poly_int
*)&save + 8B].D.6750.coeffs[0]' may be used uninitialized in this function
[-Wmaybe-uninitialized]
119 | stack_pointer_delta = save->x_stack_pointer_delta;
| ^
/home/rguenther/src/trunk/gcc/calls.c:4150:34: note: 'MEM[(struct poly_int
*)&save + 8B].D.6750.coeffs[0]' was declared here
4150 | saved_pending_stack_adjust save;
| ^
instead of the broken
/home/rguenther/src/trunk/gcc/calls.c: In function 'expand_call':
D.6750.coeffs[0]'/home/rguenther/src/trunk/gcc/dojump.c:118:28: warning: may
be used uninitialized in this function [-Wmaybe-uninitialized]
118 | pending_stack_adjust = save->x_pending_stack_adjust;
| ^
D.6750.coeffs[0]'/home/rguenther/src/trunk/gcc/calls.c:4150:34: note: was
declared here
4150 | saved_pending_stack_adjust save;
| ^
D.6750.coeffs[0]'/home/rguenther/src/trunk/gcc/dojump.c:119:27: warning: may
be used uninitialized in this function [-Wmaybe-uninitialized]
119 | stack_pointer_delta = save->x_stack_pointer_delta;
| ^
D.6750.coeffs[0]'/home/rguenther/src/trunk/gcc/calls.c:4150:34: note: was
declared here
4150 | saved_pending_stack_adjust save;
| ^
for the ltrans unit I was am investigating. I put this to more testing
but as said, I don't understand why or how it goes wrong at all ...