Re: Is gcc thread-unsafe?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Friday, October 26, 2007 - 10:25 am

On Fri, 26 Oct 2007, Andrew Haley wrote:

Note that doing so is perfectly fine.

But only for local variables that haven't had their addresses taken.

The fact is, those kinds of variables really *are* special. They are 
provably not accessible from any other context, and re-ordering them (or 
doing anything AT ALL to them - the most basic and very important 
optimization is caching them in registers, of course) is always purely an 
internal compiler issue.

But if gcc re-orders functions calls with *other* memory accesses, gcc is 
totally broken. I doubt it does that. It would break on all but the most 
trivial programs, and it would be a clear violation of even standard C.

HOWEVER: the bug that started this thread isn't even "reordering 
accesses", it's *adding* accesses that weren't there (and please don't mix 
this up with "volatile", since volatile is a totally unrelated issue and 
has nothing what-so-ever to do with anything).

		Linus
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Is gcc thread-unsafe?, Bart Van Assche, (Fri Oct 26, 7:40 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 8:09 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 8:27 am)
Re: Is gcc thread-unsafe?, Andrew Haley, (Fri Oct 26, 8:34 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 9:28 am)
Re: Is gcc thread-unsafe?, Bart Van Assche, (Fri Oct 26, 10:07 am)
Re: Is gcc thread-unsafe?, Andrew Haley, (Fri Oct 26, 10:12 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 10:25 am)
RE: Is gcc thread-unsafe?, David Schwartz, (Fri Oct 26, 11:06 am)
Re: Is gcc thread-unsafe?, Alan Cox, (Fri Oct 26, 11:08 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 11:14 am)
Re: Is gcc thread-unsafe?, Andi Kleen, (Fri Oct 26, 1:39 pm)
Re: Is gcc thread-unsafe?, Giacomo Catenazzi, (Fri Oct 26, 2:45 pm)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Fri Oct 26, 3:24 pm)
RE: Is gcc thread-unsafe?, Andrew Haley, (Tue Oct 30, 3:20 am)
Re: Is gcc thread-unsafe?, Bart Van Assche, (Fri Nov 2, 8:29 am)
Re: Is gcc thread-unsafe?, Andrew Haley, (Fri Nov 2, 8:38 am)
RE: Is gcc thread-unsafe?, David Schwartz, (Fri Nov 2, 10:18 am)
Re: Is gcc thread-unsafe?, Bart Van Assche, (Sun Nov 4, 8:13 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Sun Nov 4, 10:45 am)
Re: Is gcc thread-unsafe?, Andrew Haley, (Sun Nov 4, 10:58 am)
Re: Is gcc thread-unsafe?, Bart Van Assche, (Sun Nov 4, 11:06 am)