Click here to Skip to main content
15,886,518 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Mycroft Holmes16-Feb-22 11:36
professionalMycroft Holmes16-Feb-22 11:36 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
FreedMalloc16-Feb-22 14:26
FreedMalloc16-Feb-22 14:26 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
englebart16-Feb-22 14:52
professionalenglebart16-Feb-22 14:52 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha16-Feb-22 15:52
Memtha16-Feb-22 15:52 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
David O'Neil16-Feb-22 22:14
professionalDavid O'Neil16-Feb-22 22:14 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha17-Feb-22 5:23
Memtha17-Feb-22 5:23 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
trønderen17-Feb-22 6:40
trønderen17-Feb-22 6:40 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha17-Feb-22 6:53
Memtha17-Feb-22 6:53 

C# variables have initial values of binary zero, by language definition. I don't think C is similar, but correct me if I am wrong. I believe that there are other languages that defines initial values of zero.


Yes and no. In C++, a class-level variable will have the value that is provided by the constructor. If no constructor is explicitly defined, the default constructor will give it a value of zero BUT if a constructor is defined and that constructor fails to assign a value to the variable, it'll keep whatever garbage was already in ram. (furhter reading). A scoped variable (on the thread stack) has the dreaded "undefined behavior" if used without being initialized, and so many compilers (when not told to optimize) will populate the thread stack with the wrongest possible value in order to cause a bug to help you find places where it is accessed before being initialized (by exploding). Usually that means 0xCC repeating (at least in the case of gcc).

However, when the variable/buffer in question came from somewhere else, especially a hardware device that is not really even ram, the compiler will leave it alone because writing to it might cause the hardware to act on that data which could be cataclysmic under the wrong circumstances.
GeneralRe: Oh boy. I've given myself a challenge now. Pin
David O'Neil16-Feb-22 22:22
professionalDavid O'Neil16-Feb-22 22:22 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Richard Deeming17-Feb-22 2:08
mveRichard Deeming17-Feb-22 2:08 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
FreedMalloc17-Feb-22 5:25
FreedMalloc17-Feb-22 5:25 
GeneralCCC 2022-02-16 Pin
Peter_in_278015-Feb-22 22:03
professionalPeter_in_278015-Feb-22 22:03 
GeneralRe: CCC 2022-02-16 Pin
OriginalGriff15-Feb-22 22:05
mveOriginalGriff15-Feb-22 22:05 
GeneralRe: CCC 2022-02-16 Pin
pkfox15-Feb-22 23:19
professionalpkfox15-Feb-22 23:19 
GeneralRe: CCC 2022-02-16 Pin
OriginalGriff15-Feb-22 23:25
mveOriginalGriff15-Feb-22 23:25 
GeneralRe: CCC 2022-02-16 Pin
pkfox16-Feb-22 3:38
professionalpkfox16-Feb-22 3:38 
GeneralRe: CCC 2022-02-16 Pin
Greg Utas16-Feb-22 1:00
professionalGreg Utas16-Feb-22 1:00 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:09
professionalPeter_in_278016-Feb-22 1:09 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Greg Utas16-Feb-22 1:13
professionalGreg Utas16-Feb-22 1:13 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:20
professionalPeter_in_278016-Feb-22 1:20 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
OriginalGriff16-Feb-22 1:31
mveOriginalGriff16-Feb-22 1:31 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:31
professionalPeter_in_278016-Feb-22 1:31 
RantI'd have rather paid extra Pin
honey the codewitch15-Feb-22 19:08
mvahoney the codewitch15-Feb-22 19:08 
GeneralRe: I'd have rather paid extra Pin
Sander Rossel15-Feb-22 19:55
professionalSander Rossel15-Feb-22 19:55 
GeneralRe: I'd have rather paid extra Pin
den2k8815-Feb-22 20:51
professionalden2k8815-Feb-22 20:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.