#475839 libc6-dev: pthread_mutex_t definition contains a nameless union

Package:
libc6-dev
Source:
glibc
Description:
GNU C Library: Development Libraries and Header Files
Submitter:
Francois Gouget
Date:
2010-02-20 22:48:03 UTC
Severity:
normal
#475839#5
Date:
2008-04-13 10:12:38 UTC
From:
To:
The pthread_mutex_t in /usr/include/bits/pthreadtypes.h contains a
nameless union. This makes it impossible to use with compilers that
don't support nameless unions. Gcc 2.95 for instance. In
particular this breaks compilation of Wine with gcc 2.95 (see
loader/kthread.c in the Wine source).

Avoiding nameless unions is trivial so there's no reason not to do it.
Here's a patch to fix this (finding a better name for the union is left
as an exercise for the reader):
--- pthreadtypes.h.orig 2007-11-29 22:32:47.000000000 +0100
+++ pthreadtypes.h      2007-12-08 09:12:50.000000000 +0100
@@ -96,7 +96,7 @@
     {
       int __spins;
       __pthread_slist_t __list;
-    };
+    } u;
 #endif
   } __data;
   char __size[__SIZEOF_PTHREAD_MUTEX_T];

(hopefully this won't get too mangled by vi)


Here is a test program:
--- pthread_mutex_t.c ---
#include <pthread.h>
pthread_mutex_t mutex;
--- pthread_mutex_t.c ---

Compiling it with gcc 2.95 gives the following error:
$ gcc-2.95 -c pthread_mutex_t.c
In file included from /usr/include/pthread.h:30,
                 from pthread_mutex_t.c:1:
/usr/include/bits/pthreadtypes.h:99: warning: unnamed struct/union that defines no instances

#475839#10
Date:
2008-05-10 19:11:15 UTC
From:
To:
tag 475839 + wontfix
thanks

gcc-2.95 does not give an error, but outputs a simple warning.

I don't think it worth supporting an old compiler that is not present
in lenny. Tagging the bug as wontfix.

#475839#17
Date:
2008-12-14 22:43:24 UTC
From:
To:
[...]


I would like this bug to be reopened because I think it was closed for
the wrong reasons:

 1) gcc-2.95 is still present in Lenny. If you are not seeing it in
    aptitude, it's because you are using the 64bit build.

 2) It's very easy to get a compilation error. Just try to compile the
    following program:
--- pthread_mutex_t.c --- #include <pthread.h> pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; --- pthread_mutex_t.c --- 3) This particular construct also seems to be causing trouble with PCC: http://pcc.ludd.ltu.se/jira/browse/PCC-5 4) Wine contains code very similar to the above and thus fails to compile with gcc-2.95. This is actually the whole reason why I compile it with gcc 2.95: to ensure that Wine's code does not contain such non-portable constructs. But having the compilation fail due to the C library headers, or having to patch said headers on a regular basis, is annoying.
#475839#22
Date:
2008-12-14 23:04:42 UTC
From:
To:
The bug is still open.
#475839#27
Date:
2008-12-14 23:11:48 UTC
From:
To:
For the record, it isn't.  You may still have it installed, or you may
have Etch also in your sources.list; etch did include gcc-2.95 on some
platforms.

#475839#32
Date:
2008-12-15 10:45:26 UTC
From:
To:
On Sun, 14 Dec 2008, Francois Gouget wrote:
[...]

Ah. I see I'm wrong about this point. I still get it because I have
stable+testing in my sources.list. My other points still stand though.