https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81897

--- Comment #19 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Arnd Bergmann from comment #17)
> Created attachment 43057 [details]
> linux/drivers/scsi/lpfc/lpfc_bsg.c, preprocessed and compressed
> 
> A possibly related warning I just saw this week, with and without the gcc
> patch, and back to gcc-4.5+:
> 
> x86_64-linux-gcc-8.0.0 -fno-strict-aliasing -Wall -O2 -Wno-pointer-sign -m32
> -c -xc lpfc_bsg.i
> /git/arm-soc/drivers/scsi/lpfc/lpfc_bsg.c: In function
> 'lpfc_bsg_rport_els_cmp':
> /git/arm-soc/drivers/scsi/lpfc/lpfc_bsg.c:632:22: warning: 'bsg_reply' may
> be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> reduced to
> 8<----
> long current_stack_pointer, lpfc_bsg_rport_els_cmp_rsp_0;
> long pv_irq_ops_1_0, pv_irq_ops_0_0;
> struct bsg_job {
>   void *reply;
> };
> struct fc_bsg_reply {
>   int reply_payload_rcv_len;
>   struct bsg_job set_job;
> } * lpfc_bsg_rport_els_cmp_dd_data;
> static void check(long v)
> {
>   if (v) {
>     asm("");
>     __builtin_unreachable();
>   }
> }
> void lpfc_bsg_rport_els_cmp(void) {
>   struct bsg_job *job;
>   struct fc_bsg_reply *bsg_reply;
>   job = &lpfc_bsg_rport_els_cmp_dd_data->set_job;
>   if (job)
>     bsg_reply = job->reply;
>   check(pv_irq_ops_0_0);
>   check(pv_irq_ops_1_0);
>   asm("" : "+r"(current_stack_pointer));
>   check(pv_irq_ops_0_0);
>   check(pv_irq_ops_1_0);
>   if (job) {
>     if (lpfc_bsg_rport_els_cmp_rsp_0 == 0)
>       bsg_reply->reply_payload_rcv_len = 0;
>     else if (lpfc_bsg_rport_els_cmp_rsp_0 == 1)
>       bsg_reply->reply_payload_rcv_len = 0;
>   }
> }
> ---->8
> This looked similar to the originally reported symptom in the source code.
> The reduced version looks quite a bit different, so no idea if this is
> something else entirely or not.

This is actually not a regression to gcc 4.5 because we didn't have
-Wmaybe-uninitialized warnings then.  You are testing gcc 4.5 with -Wall, which
is different to -Wall in recent GCC's, etc.  What you want to use is
-Wmaybe-uninitialized instead of -Wall to test at which point it regresses.  I
think this likely started happening when -Wmaybe-uninitialized was implemented.

However, I agree that this warning is annoying.  Would you mind opening a new
PR with an enhancement request for this?

Reply via email to