gcc-4.7-20111022 fails to build on PA-RISC

Daniel Krügler daniel.kruegler@googlemail.com
Sun Oct 30 17:54:00 GMT 2011


2011/10/30 Jonathan Wakely <jwakely.gcc@gmail.com>:
> It turns out that the restriction on copying volatile objects
> documented in C.1.9 [diff.special] breaks std::mutex for hppa-linux,
> where pthread_mutex_t has a volatile member, so cannot be copied
> without adding a user-defined copy constructor to the underlying libc
> type, which is obviously difficult for us to do.
>
> A reduced test is:
>
> struct lock_t {
>    int lock[4];
> };
>
> struct pthread_mutex_t {
>    volatile lock_t __spinlock;
> };
>
> struct mutex {
>  pthread_mutex_t m = { };
>  mutex() = default;
> };
>
> int main()
> {
>  mutex mx;
> }
>
> One solution I can see is to undefine __GTHREAD_MUTEX_INIT etc. on
> that platform, so we use the pthread_mutex_init function instead - can
> anyone see a better alternative?

My initial idea would have been to change the member initializer to

struct mutex {
 pthread_mutex_t m{ };
 mutex() = default;
};

which should no longer use copy-initialization but direct-initialization.
But the compiler produces the same error. I believe, this is a compiler
defect in regard to handling brace-or-equal-initializers, though.

- Daniel



More information about the Libstdc++ mailing list