10
\$\begingroup\$

For instance, consider the following un-golfed submission in to some challenge requiring the use of a while looping construct:

void function() {
     int a, b;
     while(a != b) {
         // Do something
     }
}

Although the while loop would be invoked most of the time, there is an extremely small chance, but still a chance, that the un-initialized local variables a and b could start out with the same value. Is this okay? It would be nice to come to a consensus on this.

\$\endgroup\$
  • 3
    \$\begingroup\$ Well, you know, cosmic rays could also just flip your RAM too (relevant xkcd) \$\endgroup\$ – Stephen Aug 8 '17 at 20:19
  • \$\begingroup\$ similar question: here there is a well defined chance that it wont function properly (but it's way less than ~1E-303). Does anything differ in this case? \$\endgroup\$ – dzaima Aug 8 '17 at 20:54
  • 5
    \$\begingroup\$ Every sane operating system will 0-initialize all memory pages before allocating them for userspace program (because of security reasons). So it's highly unlikely that the while loop is entered \$\endgroup\$ – michi7x7 Aug 9 '17 at 11:46
20
\$\begingroup\$

No

If a program does not do what it is supposed to do, it is not valid as an answer. Otherwise we'd have to quantify what probability the answers have to work with, which is getting messy.

\$\endgroup\$

You must log in to answer this question.

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