http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55759

             Bug #: 55759
           Summary: bogus warning when building drivers/ata/libata-core.c
                    in v3.7 of the linux kernel
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: b...@alien8.de


Hi,

when building kernel v3.7 with Debian's gcc: (Debian 4.7.2-4) 4.7.2, I
get the following warning:

$  make CC=gcc-4.7 drivers/ata/libata-core.o
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CC      scripts/mod/empty.o
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      drivers/ata/libata-core.o
drivers/ata/libata-core.c: In function ‘ata_hpa_resize’:
drivers/ata/libata-core.c:1397:3: warning: ‘native_sectors’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
$

it falsely complains that native_sectors might be used unitialized. The
variable's value is assigned-to in an auxiliary function and passed to
it as a pointer.

The auxiliary function returns negative value on error and 0 on success
and its caller uses the native_sectors value returned over the pointer
only in the success case and in that case, native_sectors is always
properly initialized.

Also, gcc-4.6 (gcc-4.6 (Debian 4.6.3-14) 4.6.3) doesn't trigger that
same warning:

$  make CC=gcc-4.6 drivers/ata/libata-core.o
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CC      drivers/ata/libata-core.o
$

Thanks.

Reply via email to