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

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-28 
14:22:24 UTC ---
(In reply to comment #14)
> > --- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-26 
> > 15:18:40 UTC ---
> > Does this reduced test work with -std=gnu++11 -pthread ?
> 
> Unfortunately not, I still get
> 
> 22 : Invalid argument

IMHO it's fortunate since it's not just problem in the std::mutex code ;)

> Only if I add an explicit call to pthread_mutex_init does the testcase
> work.

Very strange, especially since the definitions you gave in comment 9 don't seem
to do anything complicated.

Does this work?

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

struct M {
  pthread_mutex_t m;
  M() noexcept {
       pthread_mutex_t tmp = PTHREAD_MUTEX_INITIALIZER;
       m = tmp;
  }
};

int main()
{
   M m;
   int e = pthread_mutex_lock(&m.m);
   if (e)
     printf("%d : %s\n", e, strerror(e));
   return e;
}

If that works, we might be able to fix it using fixincludes (similar to PR
50982 comment 32)

Otherwise I suppose we must not define __GTHREAD_MUTEX_INIT on Tru64, causing
std::mutex to use the init function instead.

Reply via email to