Re:When you see a Heisenbug in C, change your compiler's opt...
by detrino on Saturday March 01, 2014 @09:05PM
(#7327316)
C11/C++11 define a memory model and provide assorted primitives.
Re:When you see a Heisenbug in C, change your compiler's opt...
by letzjuc on Wednesday March 05, 2014 @11:41AM
(#7347960)
Indeed. It should be:
>TL;DR: concurrency is unspecified in _C99_.
Since it is specified in C11's memory model.
Re:When you see a Heisenbug in C, change your compiler's opt...
by ohazi on Saturday March 01, 2014 @08:25PM
(#7327202)
> TL;DR: concurrency is unspecified in C.
One of the many reasons I'm eagerly the 1.0 release of Rust.
Re:When you see a Heisenbug in C, change your compiler's opt...
by swordswinger12 on Sunday March 02, 2014 @12:01AM
(#7327777)
I think you accidentally a word.
Re:When you see a Heisenbug in C, change your compiler's opt...
by AaronFriel on Sunday March 02, 2014 @12:07AM
(#7327790)
Just a Heisenbug, he was using a browser written in C or C++.
Re:When you see a Heisenbug in C, change your compiler's opt...
by theseoafs on Sunday March 02, 2014 @03:12AM
(#7328237)
Looks like we've found a compiler bug. Who has Stallman's email?
Re:When you see a Heisenbug in C, change your compiler's opt...
by ohazi on Sunday March 02, 2014 @12:07AM
(#7327792)
sigh Yeah, my edit window expired. Very eagerly awaiting. :-P
Re:When you see a Heisenbug in C, change your compiler's opt...
by frozenport on Saturday March 01, 2014 @08:56PM
(#7327289)
>TL;DR: concurrency is unspecified in C.
Does the same argument apply to binary code ran on a preemptive operating systems? The actual execution order of your code is still unspecified, as the OS an interrupt it whenever it wants.
Re:When you see a Heisenbug in C, change your compiler's opt...
by Dylan16807 on Saturday March 01, 2014 @11:06PM
(#7327664)
Mostly. The OS and hardware will make certain guarantees about ordering and concurrency, and if you want more you need to specifically ask them for more. C makes almost no guarantees, but the basic concept is the same. Use the provided extensions to get safe order and concurrency.
C and C++ are specified as the behavior of a straight-line sequence of code run in isolation. Basically, any concurrent C/C++ program treads into the unspecified behavior area. Thusly it's not the optimizers fault, but C/C++ certainly aren't helping out at all.
Even the mechanisms that are common place to make a concurrent C/C++ program run correctly basically wade into unspecified behavior, for instance using asm("lock esp"), asm("mfence"), etc.
TL;DR: concurrency is unspecified in C.