A comment there said they don't see the problem (presumably due to the all-too-common "screw the human, git gud" attitude in the face of Undefined Behavior).
And I further presume that the most defensible answer is that the problem is that asking the compiler for a warning on uninitialized variable use fails in this case.
As an aside on the presumed language/standards-lawyering, as a compiler writer, I personally think that compilers should try their best to help the user, far more than trying to take the side of the language standard in a user-hostile way, but that's just me.
No, it can't. His example doesn't even contain "int i = 0". He has "int i;" followed later by an initializer that can be skipped depending on the rather funky switch logic he's added (i.e. it's undefined behavior).
Maybe other readers will be able to see that the example includes many different tests when things are declared and not initialized. The goto example specifically contains int i = 0, but users are less likely to run in to that one since it is goto.
Using an uninitialized variable is Undefined behaviour. Thats the point.
4 comments
[ 3.2 ms ] story [ 22.9 ms ] threadA comment there said they don't see the problem (presumably due to the all-too-common "screw the human, git gud" attitude in the face of Undefined Behavior).
And I further presume that the most defensible answer is that the problem is that asking the compiler for a warning on uninitialized variable use fails in this case.
As an aside on the presumed language/standards-lawyering, as a compiler writer, I personally think that compilers should try their best to help the user, far more than trying to take the side of the language standard in a user-hostile way, but that's just me.
Nothing to see here. Clickbait title.
Using an uninitialized variable is Undefined behaviour. Thats the point.