« first day (2338 days earlier)      last day (739 days later) » 

00:39
@nwp You're right, but there's a little more to it than that. The specification of UB comes later, in subclause 21.2: "The execution of a program contains a data race if it contains two potentially concurrent conflicting actions, at least one of which is not atomic, and neither happens before the other, except for the special case for signal handlers described below. Any such data race results in undefined behavior." No write->no conflict. No conflict->no UB.
 
3 hours later…
03:48
How to understand const Cat Cat::Lion(Cat::Lion_); in the code snippet below? It seems that Cat::Lion is a variable name, but it looks so strange!
Here is the said code snippet.
Is it legal that there is a :: in the variable name?
Sorry for disturbing you, guys. I understand it now. The key is static const Cat Tiger, Lion, Cheetah; . The Lion is a static member variable for class named Cat. So Cat::Lion is legal.
 
5 hours later…
08:44
How could I make a dependency in a makefile refer to the name of the target? For example for helloworld : helloworld.cpp, I want something like helloworld : [email protected], but doing that evaluates the $@ to nothing
Nevermind, this (stackoverflow.com/questions/16262344/…) answers my question
 
5 hours later…
13:48
@JerryCoffin I could pull the "But they were talking C and not C++ card" but I won't, I get what y'all are saying. In my personal experience that's been dubious. If the compiler detects it can be written to at all it seems to trigger the UB or just maybe the implementation doesn't care to sync the caches. Either way the effect is the same.
nwp
nwp
I don't think there is a contradiction. If the compiler can see a write at potentially the same time as a read then it's UB. There is no need to sync caches, unless primitives like mutexes require it to do so, but the compiler is more or less explicitly told when to do so.
I mean in theory the scenario presented the write should happen prior to thread start. Assuming (this being c) they used thrd_create then IIRC the standard does require its execution state to be synced.
nwp
nwp
I thought so too, but now that I think about it I don't see the point. The new thread is new and thus cannot have different values in cache. Or maybe it's run on a physical core which has a cache of whatever ran before which now needs to be synced. That's probably it.
I vaguely remember thread creation to be a synchronization primitive like mutex locking.
On x86 it probably doesn't make a difference anyway and I have never messed around on ARMs.
@nwp Then again, thread switching is not something the compiler needs to care about.
14:04
@nwp I've actually run into the issue on x86 ironically. Windows only so it could be an MS thing. In all fairness it was a CreateThread thread and not a std::thread or thrd_create (which AFAIK MS doesn't support yet) thread.
 
2 hours later…
16:21
@Mgetz Oh--I missed that it was C rather than C++, or I'd have stayed out of it. In my opinion, about the only reason to write new C code is for things like device drivers or embedded code that deals directly with hardware (and even the latter is questionable). For application code, I consider C at least as obsolete as COBOL...
@JerryCoffin not sure it being C really changes aught though.
@Mgetz I rather doubt that it does. But I haven't tried to keep up on the C standard for years, so I'd barely know where to start looking for quotes about what's defined (or not) about threads in C (other than that I'd have to look in a newer standard than I have right now).

« first day (2338 days earlier)      last day (739 days later) »