RE: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread skaller
On Mon, 2007-10-22 at 00:07 +0100, Dave Korn wrote: > If you really want all externally-visible accesses to v to be made exactly > as the code directs, rather than allowing gcc to optimise them in any way that > (from the program's POV) it's just the same 'as-if' they had been done > exactly, m

Re: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread skaller
On Sun, 2007-10-21 at 20:16 +0400, Tomash Brechko wrote: > But if C99 is thread-neutral, then it's compiler's responsibility to > ensure the same result as some abstract machine No. The compiler is responsible for ensuring that things work if, and only if: 1. your program conforms in required

Re: Bug in C++ FE?

2007-10-21 Thread Andrew Pinski
On 10/21/07, Rene Buergel <[EMAIL PROTECTED]> wrote: > When i'm trying to compile the following Code: > method = &X::some_func; You forgot the template keyword as X is dependent : method = &X::template some_func; There is a defect report against the C++ standard about X being depende

Bug in C++ FE?

2007-10-21 Thread Rene Buergel
When i'm trying to compile the following Code: template class X { private: typedef void (X::*PtrToMethod)(); PtrToMethod method; template void some_func() { return; } public: void func() { method = &X::some_func

RE: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread Dave Korn
On 21 October 2007 15:55, Tomash Brechko wrote: > Consider this piece of code: > > extern int v; > > void > f(int set_v) > { > if (set_v) > v = 1; > } > f: > pushl %ebp > movl%esp, %ebp > cmpl$0, 8(%ebp) >

Re: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread Richard Guenther
On 10/21/07, Tomash Brechko <[EMAIL PROTECTED]> wrote: > On Sun, Oct 21, 2007 at 17:26:02 +0200, Erik Trulsson wrote: > > Note that C99 is firmly based on a single-threaded execution model and says > > nothing whatsoever about what should happen or not happen in a threaded > > environment. Accordi

Re: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread Tomash Brechko
On Sun, Oct 21, 2007 at 17:26:02 +0200, Erik Trulsson wrote: > Note that C99 is firmly based on a single-threaded execution model and says > nothing whatsoever about what should happen or not happen in a threaded > environment. According to C99 a C compiler is allowed to generate such code > as gc

Re: Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread Erik Trulsson
On Sun, Oct 21, 2007 at 06:55:13PM +0400, Tomash Brechko wrote: > Hello, > > I have a question regarding the thread-safeness of a particular GCC > optimization. I'm sorry if this was already discussed on the list, if > so please provide me with the reference to the previous discussion. > > Consi

Optimization of conditional access to globals: thread-unsafe?

2007-10-21 Thread Tomash Brechko
Hello, I have a question regarding the thread-safeness of a particular GCC optimization. I'm sorry if this was already discussed on the list, if so please provide me with the reference to the previous discussion. Consider this piece of code: extern int v; void f(int set_v) {