Am Sonntag, den 07.09.2014, 11:16 -0400 schrieb Rich Felker: > On Sun, Sep 07, 2014 at 04:45:01PM +0200, Jens Gustedt wrote: > > Am Sonntag, den 07.09.2014, 07:32 -0400 schrieb Rich Felker: > > > I'm not clear on whether the assignment is well-defined in pthreads, > > > but actually attempting to use the mutex (by passing it to any of the > > > pthread_mutex_* functions) would be UB. The same should be true for > > > C11 threads; if not, it's a defect. > > > > It is. > > It is a defect? Or..? sorry, I meant it is a defect. Yet another proof of the severe lack of specification and semantic that this whole C thread thing has in the standard. > > sure, we all (should) know that, but the average user wouldn't > > > > > I don't think the committee intended to forbid any of the above types > > > of implementation; on the contrary it seems they went out of their way > > > to support crazy types of implementations, e.g. by omitting > > > initializers. > > > > No, unfortunately for the later, the lack of a definition for default > > initialization and initializers seems to be intentional. There are > > people on the committee who defend the interdiction of statically > > initialized mutexes, seemingly because some oldish windows thread > > implementation didn't have it. > > That's what I mean. By refusing to support static initialization of > mutexes, they seem to be supporting the possibility of implementations > for which static initialization is impractical, much like some of the > crazy ideas I mentioned above. Even with those crazy ideas it is easily possible to have the corresponding function do such a lacking initialization based on a default 0 initialized field, in the same way pthread_once_t works. This is a bit of an overhead at each call, but I wouldn't mind at all penalizing any implementation that deviates from the "all-default-initialization-is-0" rule. That's already something the standard has for years for pointers and floating point. A platform may have different representations for null pointers or for 0.0. But it is the problem of the platform provider to do everything that 0 initialization does the right thing, and not to leave such crazy thing to the user of the type. Jens -- :: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS ::: :: ::::::::::::::: office Strasbourg : +33 368854536 :: :: :::::::::::::::::::::: gsm France : +33 651400183 :: :: ::::::::::::::: gsm international : +49 15737185122 :: :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::