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

Jonathan Wakely jwakely.gcc@gmail.com
Sun Oct 30 20:04:00 GMT 2011


On 30 October 2011 19:23, Daniel Krügler wrote:
> 2011/10/30 Jonathan Wakely <jwakely.gcc@gmail.com>:
>> Unfortunately in the real case the initializer is an opaque macro,
>> PTHREAD_MUTEX_INITIALIZER, which could be something unsuitable for
>> that syntax, such as an integer constant.
>>
>> The only reliable way to use that macro is:
>>
>> pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
>>
>> which requires copy-init.
>
> Here I'm having a logic problem: Obviously the above syntax
> is supposed to be well-formed (Let's ignore for the moment
> what the macro does). Given that fact, I would argue that
> it should also be well-formed as part of any brace-or-equal-initializer
> or a non-static data member. Am I missing something here?

It's well-formed in C, but for the Linuxthreads implementation it's
not well-formed in C++ because of the volatile member.  That's because
of the incompatibility between C and C++, as listed in Annex C.

> What I'm trying to say here is, that if the volatile-member-
> and-copy-initialization-semantics reason would be correct,
> no-one could portably use
>
> pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
>
> in block scope or namespace scope without creating ill-formed
> code. There must be something obvious that I'm failing to see...

Right, it's ill-formed at block scope too so the initializer can't be
used in C++, which is a problem in the Linuxthreads headers, but we
need to workaround if we want to make std::mutex work on hppa-linux
and other platforms using Linuxthreads.



More information about the Libstdc++ mailing list