« first day (564 days earlier)      last day (4375 days later) » 

Time to write has_common_type I suppose.
 
OK so I've added ignored tags, I just get greyed-out posts I have to scroll through yet more
 
@stdOrgnlDave What do you mean with "SFINAE works perfectly well", btw?
 
Is it sound for apply(visitor, variant) to return a common type if there is one by default?
 
@RMartinhoFernandes a template constexpr function (if you can template constexpr's?) specialization
specialize the constexpr to return 0 if it's 0, or the value if it isn't
hmm, wait, y would need to be known at runtime too, sigh
too simplistic :-( too late at night
 
3:04 AM
Like if the visitor is struct const_zero { double f(int) { return 0; } template <typename T> int f(T&&) { return 0; } }; it returns double instead of variant<int, double>?
 
Yeah. I'm trying to see if there is the potential for e.g. lossy conversions (I'm aware that you usually frown upon the loss of information of having less members in the resulting variant).
 
I repeat myself: OK so I've added ignored tags, I just get greyed-out posts I have to scroll through yet more
 
@RMartinhoFernandes Nice! All but 2 of those are regulars here?
@stdOrgnlDave Make sure you add favorite tags as well. Anything on your favorites list will be highlighted in yellow.
 
@LucDanton I'd say, leave apply as is, and provide a to_common_type function that collapses a variant into a common type if possible.
 
3:07 AM
@RMartinhoFernandes Considering you can do common(apply(const_zero {}, variant)) I should really stick to the behaviour I have currently.
 
Oh, you had that already.
 
@RMartinhoFernandes Normally I'd 'great minds etc.' you but I've revoked your privileges regarding that >:(
So, trying to figure out why <int&&, int> results in <int> and not variant<int, int&&>.
 
so there's no way to outright ignore my ignored tags
just, NOT DISPLAY them
 
user406009
I think I just found a possible bug in gcc.stackoverflow.com/a/10407182/406009
 
@Mysticial I've had the 400 upvotes thing for months now, but I only provided the 80th answer today.
@stdOrgnlDave Your profile's preferences page has something like that.
 
3:10 AM
Ooh, it's for the C++11 tag... at first I thought it was for C++, which I found weird because I already have that one.
 
@EthanSteinberg Doesn't -O3 turn on unsafe floating-point optimizations?
I guess not.
"-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload, -ftree-vectorize, -ftree-partial-pre and -fipa-cp-clone options. "
 
@EthanSteinberg You know, the compiler can do the optimization on the ints.
 
YAY thank you
 
@Ethan Now it has UB!
You can't scanf with %f into an int.
 
@RMartinhoFernandes I think I have like 7 or 8 tags like that. 400+ but less than 80 anwers.
 
user406009
3:15 AM
Fail on my part.
 
@Mysticial Kerrek used to be around, but I haven't seen him here in a while. Other than that only Xeo and Johannes.
Howard is on the committee, and Nicol is a game programmer.
 
Kerrek does drop-in from time to time though.
 
user406009
Ok, I think I am done making a fool of myself. Goodnight to all.
 
lol, night
 
Good night.
 
3:20 AM
0
A: Posix Threads - Threads in Parallel

std''OrgnlDaveEach thread will look at the global variable 'total' 100 times. However, each thread gets its own local copy, decrements that, and writes it back to the global variable, total. Conceivably, total may go down by no more than 100, as they both grab total in synchrony, decrement their local copy, ...

 
Weird. I have Invoke<meta::Bind<make_variant_over, some_metacomputation>> which has a clear bug in that I don't Invoke the some_metacomputation, yet the program still has semantics?
 
oops
Do I even make sense late at night? Sigh
I mean I could go into how each thread will probably get done with 'total' before the interrupt timer even hits for it to switch to the other thread since the loop is so small, but...blah
 
@LucDanton What does the program do? I suppose some_metacomputation is at least default constructible.
 
@RMartinhoFernandes apply(visitor, v) returns int.
And in fact adding the missing Invoke changes nothing apparently. Still returns int, warning about reference to temporary.
Better check that the relevant specialization is being used here.
 
any comments on that question answer before I go
 
3:24 AM
I know race conditions are undefined behavior in C++11. Anyone know the status for C11?
 
that isn't a race condition
reading an int from memory doesn't create a race condition under pthreads in c
it just does a mov %eax, address
 
@stdOrgnlDave That's specified by POSIX?
Because C++11 explicitly states that it is undefined behavior.
 
do you even know what undefined behavior is?
 
@stdOrgnlDave Of course I do.
 
@Mysticial data races
Benign race conditions are okay.
 
3:26 AM
in this case the behavior is exactly defined:
 
I'd think it's UB in C, too.
 
each "copy of function" sees a global variable
 
It's not sane otherwise.
 
Sure it might compile to something that looks atomic, but weird things may happen when you consider x86's relaxed memory model with caches and stuff.
 
each one grabs, decrements, and writes global variable
in tandem it can result in total being brought down to 198 if the timing is just right
it can be anywhere from 0-199
but it's very defined
 
3:27 AM
It can be 200.
 
From what I can make of this answer:
366
A: C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?

NemoFirst, you have to learn to think like a Language Lawyer. The C++ specification does not make reference to any particular compiler, operating system, or CPU. It makes reference to an abstract machine that is a generalization of actual systems. In the Language Lawyer world, the job of the progr...

 
Data races are explicitly UB in C++11, no point arguing about that.
 
It seems UB to me. Or am I misinterpreting something.
@CatPlusPlus Yeah, that's what I'm thinking too...
 
saying it's UB is like saying vector<vector<string>> is undefined behavior because the standard didn't cover exactly what happens when you make a vector<vector<string>>
 
If two threads write to the same memory location without one being sequenced-before the other, it's UB.
 
3:28 AM
No, it's not like that.
 
@stdOrgnlDave The standard covers that.
 
@RMartinhoFernandes surely you understand the spirit of what I'm saying
 
UB is UB. There are no grades of UB.
 
anyway, the memory model of C explicitly allows for this, and allows it to be fail
 
@stdOrgnlDave No, I don't.
> The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior.
 
3:30 AM
@RMartinhoFernandes the standard actually lists vector<vector<string>>? Or are you saying you deduce what happens by the rules of it
 
Study std::vector<T> for T = std::vector<std::string> which entails studying std::vector<T> for T = std::string.
 
This is an entirely pointless analogy.
 
@stdOrgnlDave It has rules for it.
Just like it has rules for when two threads write to the same memory location: those rules explicitly say it's UB.
 
and C has rules for its memory model. the rules are basically, 'treat it as if it's one thread, and if there's two going, well, you better make sure you're doing mutexes because the compiler is treating it that way"
 
Really? Can you quote?
 
3:32 AM
@stdOrgnlDave [citation-needed]
 
I'd have to cite multiple sections including sections of pthreads. this is not the time for that.
 
I can already rules that look pretty strict in 3.14 although this starts with "NOTE 1", I'm not familiar enough with the C Standard to know if those are normative (I'm using 1570).
> NOTE 1 Two threads of execution can update and access separate memory locations without interfering with each other.
 
it is deduced to be defined behavior just as vector<vector<string>> is deduced to be defined, even though the standard doesn't explicitly say "you can make a vector of a vector of a string"
 
25 The execution of a program contains a data race if it contains two conflicting actions in
different threads, at least one of which is not atomic, and neither happens before the
other. Any such data race results in undefined behavior.
 
3:34 AM
Okay 5.1.2.3 contains a definition of sequence-before.
 
@CatPlusPlus That matches the C++ text verbatim.
 
Make of that what you will.
 
@CatPlusPlus That looks copy and paste from C++11. So yeah, UB in both C11 and C++11.
 
That's not really surprising.
 
It makes sense that the memory model is compatible (or exactly the same).
 
3:35 AM
indeed, C11 says that.
C99? C89?
 
@stdOrgnlDave "There is only one thread".
 
Whoops, where did those goalposts go?
11 mins ago, by Mysticial
I know race conditions are undefined behavior in C++11. Anyone know the status for C11?
 
@stdOrgnlDave Prior versions of C and C++ don't even have concurrency in their specification. So it doesn't make sense to talk about it from the standards point of view.
 
Oh look, they went nowhere.
 
@LucDanton goal posts?
 
3:37 AM
You know, the things that mark the area that you have to shoot the ball through in order to score?
 
@Mysticial well that's not true, C99 has concurrency in the specification., but what you're saying is more or less my point: the defined behavior is for each thread to treat it in a naive way
 
C99 doesn't mention thread.
 
well, I shouldn't say C99, I should say GNU C library, things like sig_atomic_t
 
Which is probably the same memory model as C++03.
 
Can anyone explain me why this program (http://pastebin.com/Gh02MPYT) produces this output Child PID: 4891, Parent PID: 4890

PID: 4890, Parent PID: 4535, Child PID: 4891O
 
3:41 AM
eupdated my answer
 
as if it directly goes to the "else if condition" part 1st
 
@FailedNoob here's why:
 
It forks into two. What's the problem?
 
make it an SO question and I'll answer it, it's a multi-line answer
he's wondering why the parent ID is returned as the OS parent ID, it's a misunderstanding of fork()
 
You get printf from the forked process and the original one.
 
3:44 AM
my account is freezed , cant post any questions
This is what I get when i try to ask a question "Sorry, we are no longer accepting questions from this account. See goo.gl/C1Kwu to learn more."
 
@Failed_Noob Eh
 
fork()>0, the return is the process ID of the child you have created
fork()==0, you are the child
you're looking at it backwards
 
even if that is true ...only one of the if condition should have been executed
 
Do you know what fork() does?
 
it creates a process
 
3:47 AM
Wait, why is is_lock_free a member function?
 
It creates a fork() so you can stab people with.
 
@FailedNoob once you fork() you have two processes going. they both print to the terminal. why do you think only one would run?
 
spork()
 
@Pubby There should be a non-member version. Although that just begs the question why it operates on objects and not types, right?
 
3:48 AM
@Failed_Noob Check the "Return Value" section of the manual page.
 
@LucDanton That's what I don't get. Could it really differ between instances?
 
"Upon successful completion, fork() shall return 0 to the child process and shall return the process ID of the child process to the parent process. Both processes shall continue to execute from the fork() function. Otherwise, -1 shall be returned to the parent process, no child process shall be created, and errno shall be set to indicate the error. "
Got it ^_^
 
@FailedNoob yep. so your output is exactly as expected
now go find a random answer of mine and upvote it, so that I can get rep for that
:-P
 
Yes I understand, Thanks a lot evryone
 
3:51 AM
Hey, want to play hell with your boxen? Use fork() to generate a tree structure!
fork() > recursion
 
fork bomb vs spoon missile, who wins?
 
wont that make the CPU utilization go up ?
 
@FailedNoob yes, and it makes it necessary to get inter-process IO going, and it's stupid. it's sort of a joke
 
@Pubby Sounds like an interesting SO question.
 
3:53 AM
lol
 
is spoon missile an actual programming thing?
 
@RMartinhoFernandes I don't need extra rep, you can ask it!
 
atomic_is_lock_free requires an instance as well...
@Pubby I'm researching :)
 
@RMartinhoFernandes Oh, were you talking about is_lock? I thought you wanted me to ask about spoon missiles.
 
3:55 AM
Yeah, I'll ask that on SO
 
Who here told me not to use cute variable names, as per Clean Code?
 
OMG I was totally a help vampire on gamedev stackexchange
 
 
by accident
 
I bought it.
 
3:57 AM
'cute variable names'?
for (int fluffy_bunny = 1; fluffy_bunny < 16; fluffy_bunny *=2;) { } // Because fluffy bunnies MULTIPLY LIKE RABBITS
 
#define absolutelyFreakinNot false
 
@Mysticial Hey, I've been working on that allocator I mentioned once. Only very basic functionality so far, although I do plan on resuming work at some later point. Does this usage look sensible to you?
 
Someone then quoted that book. So I ordered it.
 
#define fuck_yeah_baby true
#define fucking_no_way false
2
 
I like my fluffy bunny loop; it is a great programming pun
#define fucking_stupid_crap 0.000001f
 
3:59 AM
0
Q: Why is is_lock_free a member function?

PubbyWhat is the reason for why is_lock_free requires an instance (it's a member function)? Why not a metafunction of the type, or a static constexpr member function? I am looking for an actual instance of why it is necessary.

 
@Moshe One day I'll understand the connection between M104 and code.
 

« first day (564 days earlier)      last day (4375 days later) »