This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: mutex failing (stupid C++!)
- From: Ian Lance Taylor <iant at google dot com>
- To: skaller <skaller at users dot sourceforge dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 31 Oct 2007 08:19:14 -0700
- Subject: Re: mutex failing (stupid C++!)
- References: <1193808489.8355.22.camel@rosella.wigram>
skaller <skaller@users.sourceforge.net> writes:
> Arggg .. C++ is such a mess.. look at this and spot the bug:
>
> {
> flx_mutex_locker_t (*ehd->spawner_lock);
> fprintf(stderr,"Thread %p acquired mutex\n", pthread_self());
> *ehd->spawner_flag=true;
> ehd->spawner_cond->broadcast();
> fprintf(stderr,"Thread %p releasing mutex\n", pthread_self());
> }
>
> This baffled me for 3 days now. The code is legal, it just
> doesn't do what I expected. The fix is ONE CHARACTER.
I assume the problem is that you didn't name your lock.
I think the question is: could g++ issue a warning for this code which
would have helped you identify the problem?
Ian