[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#195834: gcc: bogus warning and/or mis-optimization on ia64



Package: gcc-3.3
Version: 3.3-2

| troup@merulo:~/gdbm-1.8.3$ gcc -O2 -Wall -c gdbmopen.c
| gdbmopen.c: In function `gdbm_open':
| gdbmopen.c:15: warning: `lock_val' might be used uninitialized in this function

|   fstat (dbf->desc, &file_stat);
|
|   if ((flags & GDBM_OPENMASK) == GDBM_READER)
|   {
|       if (dbf->file_locking)
|         {
|           struct flock flock;
|           flock.l_type = F_RDLCK;
|           flock.l_whence = SEEK_SET;
|           flock.l_start = flock.l_len = 0L;
|           lock_val = fcntl (dbf->desc, F_SETLK, &flock);
|         }
|     }
|   else if (dbf->file_locking)
|     {
|       struct flock flock;
|       flock.l_type = F_WRLCK;
|       flock.l_whence = SEEK_SET;
|       flock.l_start = flock.l_len = 0L;
|       lock_val = fcntl (dbf->desc, F_SETLK, &flock);
|     }
|   if (dbf->file_locking && (lock_val != 0))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|     {
|       return NULL;
|     }

I think this warning is bogus because a) it only happens on ia64
(AFAICT, it doesn't happen on arm, i386 or hppa, at least), b) it only
happens with optimization turned on (disappears with -O0) and
c) if the (entirely unrelated) fstat call is commented out, the
warning disappears.  I also think that it's clear from the code above
that lock_val couldn't be used uninitialized unless I'm missing
something embarrassingly obvious.  Unfortunately I haven't been able
to determine if it's just a bogus warning or if the code's actually
being mis-compiled.

This isn't a regression, all previous versions of gcc (2.96, 3.0 and
3.2) for ia64 have the same problem and gcc-snapshot (20030531-2)
doesn't fix it.

http://people.debian.org/~troup/gcc/gdbm/ contains gdbmopen.{c,i},
fixed-gdbmopen.{c,i} (i.e. with the fstat commented out) and
orig-gdbmopen.{c,i} (the unreduced original file from gdbm 1.8.3).

-- 
James



Reply to: