This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20099] -pthreads should imply -fno-threadsafe-statics
- From: "qrczak at knm dot org dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2005 22:37:24 -0000
- Subject: [Bug c++/20099] -pthreads should imply -fno-threadsafe-statics
- References: <20050220004607.20099.davids@webmaster.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From qrczak at knm dot org dot pl 2005-02-24 22:37 -------
> By your definition of MT-safe, almost no function is MT-safe. Is 'strchr'
> MT-safe if you call it on a string while another function might modify that
> string? No, so lets put automatic locks around 'strchr' and any function that
> might modify a string.
The difference is that almost all uses of strchr are done on data which is not
shared between threads, while many static local initializers are used on objects
which are accessed from multiple threads (when multiple threads are used at all).
By your reasoning malloc should be unsafe to use from multiple threads if the
user did not explicitly put a lock around it, because it modifies shared data
(the heap). And errno should not be automatically made thread-local, because it
hurts performance in case thread-locality is not needed. After all, "POSIX puts
the responsibility fully on the application programmer to place locks where
there might be concurrent access. In exchange for this effort, the programmer
gets the performance benefit of there not being locks when they are not needed".
Right?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20099