jack: (Default)
[personal profile] jack
In C and C++, you should avoid using an uninitialised variable for several reasons, not least of which, it's undefined behaviour (?) But in practice, what are the relative likelihoods of the (I think?) permitted outcomes:

(a) it being treated as some unknown value
(b) the following code being deleted by the compiler
(c) something even weirder happening?

Date: 2016-06-06 02:48 pm (UTC)
damerell: (computers)
From: [personal profile] damerell
I think the most likely outcomes are a) variable assumes random value and d) compiler notices and refuses to compile.

But you are correct that any of your outcomes are possible because in the case of undefined behaviour the compiler is allowed to do anything it likes - b) and c) and making green demons fly out your nose included.