-8

The question Is uninitialized local variable the fastest random number generator?'s accepted answer currently has 256 upvotes, trumping the second upvoted answer by 116 upvotes and a better answer (one that earned a 200 point bounty) by 120. The comments express why this answer is problematic:

[+5] There's no such thing as an "uninitialized register" on any architecture. The machine doesn't understand initialization or lack thereof; it's a language construct.

[+47] I really object to the "it kind of works" notion. Even if it was true today, which it is not, it might change at any time due to more aggressive compilers. The compiler can replace any read with unreachable() and delete half of your program. This does happen in practice as well. This behavior did completely neutralize the RNG in some Linux distro I believe.; Most answers in this question seem to assume that an uninitialized value behaves like a value at all. That's false.

[+19] Also, I'd fire you seems a rather silly thing to say, assuming good practices this should be caught at code review, discussed and should never happen again. This should definitely be caught since we are using the correct warning flags, right?

[+2] I have to agree with @usr here, you can see my live godbolt examples in my answer, at least for clang this does not kind'of work.

[+14] This answer makes it sound as if "invoking undefined behavior is bad in theory, but it won't really hurt you much in practice". That's wrong. Collecting entropy from an expression that would cause UB can (and probably will) cause all the previously collected entropy to be lost. This is a serious hazard.

[+6] "I'd fire you?" What an arrogant thing to say. He was trying to come up with a creative way of solving a problem. Hopefully nobody works for you.

I could go on but I'll stop there. Furthermore, the "better" answer (the one that earned a bounty) has the following comments on it:

[+4] It is very unfortunate that this answer (which is well written, well cited, researched and correct) is voted lower than the top answer (which is at least misleading, in my opinion).

@TheodorosChatzigiannakis considering my answer came almost six hours after the question was asked I am doing pretty well. With these hot network question it is very hard to overcome first mover advantage. I only added my answer because the existing answers really left out a lot of important points. Most likely the only way I will end up on top is if the OP accepts my answer.

None of the tools to combat this seemed to have worked:

  • The bounty gave the "better" answerer some points, but doesn't affect its ranking. If anything, bounties just give the question more attention, which leads to more upvotes to the accepted answer.

  • Downvotes take forever to drown out upvotes. It's unlikely the people upvoting the accepted answer will read the comments, the other answers, or have the technical prowess to determine which answer is better.

So I bring this to meta. What can be done about this?

6
  • 5
    The OP accepted an answer that worked best for them. Users agree and disagree so community voting is on its way. What do you want us to do. Upvote what you think should be the accepted/better answer? I down voted all answers and upvoted the accepted answer, because I can...
    – rene
    Commented Aug 26, 2015 at 7:41
  • @rene So you're telling me we shouldn't be voting on technical correctness? Commented Aug 26, 2015 at 8:02
  • 1
    You should vote on if the answer is useful or not. It looks like the question already starts out as technical doubtful so it immediately divides the community in two camps, the purists users and the practical focused users. Both camps provide answers, both camps learn new tricks, they hate to admit it might work. Given the question, any answer can be correct, depending on your viewpoint.
    – rene
    Commented Aug 26, 2015 at 8:09
  • Good to know. When I get enough rep, I'll start downvoting answers just because I can then. Commented Aug 26, 2015 at 8:23
  • 1
    @user5267304: that's not how the voting system works.
    – Cerbrus
    Commented Aug 26, 2015 at 9:10
  • These kind of questions really hurt me (the one linked to I mean). I know for SO you don't need a specific reason to ask a question. That does not stop a million alarm bells from going off in my head when I read it. why do you even care if it is faster or not? There are so many more interesting and important questions to ask first! Most of the answers actually go ahead and address the unvoiced far more interesting questions.
    – Gimby
    Commented Aug 26, 2015 at 11:52

2 Answers 2

2

First off there is no accepted answer on that question, nor did it had an accepted answer anywhere in the timeline

There is not much that needs to be done here I think. The question it self is interesting from a theoretical perspective and maybe useful if you want to understand undefined behavior in your own code.

All the answers address the issue raised in the question to some extent. I didn't find any so far that says It's perfectly fine what you're trying to achieve, I use that trick myself in my production code.

The question was somewhere on the hot question lists based on some comments. That attracts more voters, probably also votes from users that aren't familiar with c++ or maybe even with the concept of undefined behavior.

The top voted answer has 272 up votes and 16 down votes.
The second voted answer is +142 / -2
The third voted answer is +139 / -3
The fourth votes answer is +35 / -3

As you can see the highest voted answer got also more down votes then the other answers. The answer it self basically expands on the existing ones by adding observations and a personal view on how software engineers that introduce this kind of undefined behavior should be handled. That might give it some popularity votes. Why users vote is still a mystery. Don't ask about the large group that don't vote at all....

None of the highest voted answers seem wrong so I don't think a large group of the community would feel the need to correct the voting based on the evidence or reasoning you present in your question.

Now that you brought the question to the attention of the meta crowd you might see some meta-effect occur. I don't dare to predict the outcome of that effect.

3
  • It has to be one hell of a meta effect to make a dent in the current vote rankings on that question.
    – Cerbrus
    Commented Aug 26, 2015 at 9:22
  • I agree on that ... Might need all my sock puppets ;)
    – rene
    Commented Aug 26, 2015 at 9:23
  • 1
    All of them? That's disappointing ;-)
    – Cerbrus
    Commented Aug 26, 2015 at 9:24
2

When you google the exact question title then you can easily see how this happened. You get hits on english.se, math.se, superuser.com, sites where this kind of question is not on topic. But can still show up, this Q+A was featured in the Hot Network Questions list. The one you see on the ==> right of this page.

Enough to explain the very large number of views, over 11K in less than a month, as well as the heavy voting for posts and comments.

UB is attractive to C and C++ programmers like a moth is attracted to an open flame. Everybody has an opinion about it, usually colored by which particular way a program they worked on before behaved randomly in an incredibly hard to diagnose way. Why something crazy like this exists in popular programming languages is not addressed by any of the popular answers. Only one answer that uses the traditional "nasal daemon" metaphor so likely to be a new generation of programmers that have to learn this the Hard Way all over again. This is doomed to come up over and over again, like it already has in many previous Q+A.

Just entertainment, it is pretty harmless. Google ignores it and puts non-SO pages first.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .