[cfe-dev] [PATCH] Make libcxx compile on x86_64 Linux w/ g++ 4.4.3

Sebastian Redl sebastian.redl at getdesigned.at
Wed Jun 2 10:25:23 PDT 2010


Howard Hinnant wrote:
> Thanks Matt.  What is pthread_t on your system?  And are you sure that assigning NULL to it is putting it into a state that means "not a thread"?
>   
glibc defines pthread_t as unsigned long. Assigning NULL to it is
definitely not a good idea; at the very least, GCC ought to generate
warnings about the misuse of NULL. (And so would Clang.)

I've looked at the Single Unix Specification, and I don't think
pthread_t is supposed to even have a "not a thread" value. So you can
either go the separate bool way for glibc systems, or look at the glibc
code to find a valid sentinel and pray they don't change anything.

For what it's worth, current glibc stores a pointer in pthread_t too, so
0 can probably be used as a sentinel for now. That said, be aware that
it unconditionally dereferences that pointer, so if you accidentally
pass it to a pthread_* function, you'll get a segmentation fault, not an
error.

Sebastian



More information about the cfe-dev mailing list