Uninitialised variable
Jun. 6th, 2016 12:57 pmIn 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?
(a) it being treated as some unknown value
(b) the following code being deleted by the compiler
(c) something even weirder happening?
no subject
Date: 2016-06-06 04:55 pm (UTC)For example, if I write: char c; int i = c; f(i); it's entirely possible for f to be passed 227316459 as its argument, even though that's not a value a char can have. Leaving aside that the compiler would complain bitterly about a case that artificial and obvious, then applying option b.