public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60178] New: std::mutex::try_lock failing
@ 2014-02-13 15:19 meme02 at eaku dot net
0 siblings, 0 replies; only message in thread
From: meme02 at eaku dot net @ 2014-02-13 15:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60178
Bug ID: 60178
Summary: std::mutex::try_lock failing
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: meme02 at eaku dot net
Created attachment 32124
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32124&action=edit
Output from g++ -save-temps command above.
Problem summary:
The very simple standard example code for std::mutex usage here:
http://en.cppreference.com/w/cpp/thread/shared_mutex/unlock
-------------------
#include <iostream>
#include <mutex>
int main()
{
std::mutex test;
if (test.try_lock()) {
std::cout << "first try_lock successful\n";
} else {
std::cout << "first try_lock NOT successful\n";
return 0;
}
test.unlock();
test.lock();
if (test.try_lock()) {
std::cout << "second try_lock successful\n";
} else {
std::cout << "second try_lock NOT successful\n";
}
test.lock(); // trying to lock an already-locked std::mutex will
// block program execution, so we'll hang here
}
-------------------
... does not perform as it should. On my system:
-------------------
[bash]$ rm -f test; /usr/local/bin/g++ -save-temps -Wall -Wextra -std=c++0x
test.cpp -o test; ./test
first try_lock successful
second try_lock successful
[bash]$
-------------------
Obviously, the second try_lock should fail and the program should then hang,
but this does not occur.
I'm running the latest gcc stable tarball, 4.82, updated today, no flags given
at build time. I was previously using 4.62 and the problem was there too (I
upgraded to see if that would fix it). /proc/version says "Linux version
2.6.18-194.el5PAE (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2
20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 22:00:21 EDT 2010".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-13 15:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13 15:19 [Bug c++/60178] New: std::mutex::try_lock failing meme02 at eaku dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).