When compiling the source with "-Wall -O", gcc gives the following warning:

% gcc -c -Wall -O gcc_test.c
gcc_test.c: In function ?functionLeon?:
gcc_test.c:11: warning: ?reference? may be used uninitialized in this function

% cat gcc_test.c
#include<stdio.h>

typedef struct {
  int yb;
} TCRData;

void functionLeon (TCRData *pParent, int pBool);
void functionLeon (TCRData *pParent, int pBool)
{
    int isRootCell;
    TCRData *reference;

    isRootCell = (pParent == NULL);

    if (!isRootCell)
        reference = pParent;

    if (pBool) {
       if(!isRootCell)
          reference->yb++;
    }
}

% gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../../src/gcc-4.4.0/configure
--prefix=/remote/depotsrc/depotsrc/amd64-2.4/local_install/gcc-4.4.0
--enable-bootstrap --enable-shared --enable-threads=posix --disable-checking
-with-gmp=/remote/depotsrc/depotsrc/amd64-2.4/local_install/gmp-4.3.1
--with-mpfr=/remote/depotsrc/depotsrc/amd64-2.4/local_install/mpfr-2.4.1
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,fortran --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.0 (GCC)


-- 
           Summary: "may be used uninitialized" compiled with "-Wall -O"
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: numidee at synopsys dot com
 GCC build triplet: x86_64-redhat-linux


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

Reply via email to