This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/81958] New: spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1


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

            Bug ID: 81958
           Summary: spurious -Wmaybe-uninitialized warning in gcc-8, or
                    with -O1
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

building many random configurations of the linux kernel using a gcc-8.0.0
snapshot (20170821) found a couple of bugs with -Wmaybe-uninitialized, but also
added one warning for code that does not appear to have any uninitialized use,
reduced test case follows:

__attribute__ ((__cold__)) int printk();
struct lpfc_queue {
        int queue_id;
        struct lpfc_queue *hba_eq;
} *cq_phba;
void lpfc_debug_dump_all_queues(unsigned maxidx)
{
        struct lpfc_queue *eq;
        unsigned eqidx;
        printk();
        for (eqidx = 0; eqidx < maxidx; eqidx++) {
                eq = &cq_phba->hba_eq[eqidx];
                if (eq->queue_id)
                        break;
        }
        if (eqidx == maxidx)
                eq = &cq_phba->hba_eq[0];
        printk(eq);
}

$ x86_64-linux-gcc-8.0.0 -Wall -Werror=maybe-uninitialized -Werror -O2 -c
lpfc_debugfs.c
lpfc_debugfs-e-21.i: In function 'lpfc_debug_dump_all_queues':
lpfc_debugfs-e-21.i:22:10: error: 'eq' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
          printk(eq);
          ^~~~~~~~~~

Older versions warn for -O1 and -Os but not for -O2, while gcc-8.0.0 currently
warns for all optimization levels.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]