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 c/33631] New: auto structure not initialized correctly


Compiling the following (on Fedora 7 x86_64) with "-Wall -O3" gives

  d.c:11: warning: ?r.c? is used uninitialized in this function

and as it says, doesn't initialize the .c member though it should.

#include <stdio.h>
#include <pthread.h>

int main(int c, char **v)
{
    int j[3];
    struct { int c, *j; pthread_mutex_t m; } r = {
       .j = j, .m = PTHREAD_MUTEX_INITIALIZER,
    };
    printf("current should be zero but is %d\n", r.c);
    return 0;
}

$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/home/radford/local --enable-languages=c
Thread model: posix
gcc version 4.2.1


-- 
           Summary: auto structure not initialized correctly
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: radford at blackbean dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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