this post was submitted on 26 Feb 2024
309 points (97.2% liked)

Programmer Humor

32495 readers
259 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] P1r4nha@feddit.de 6 points 8 months ago (1 children)

Yep, variables that are merely declared are not initialized, so their value is not guaranteed. Could be anything.

[–] waz@lemmy.world 1 points 8 months ago (1 children)

Correct me if I'm wrong, but I'm pretty sure some compiler settings can change this. I have a fuzzy memory of a bug that went away when compiled with debug flags enabled and the difference was that unassigned variables were being zeroed vs not zeroed.

[–] P1r4nha@feddit.de 2 points 8 months ago

Yes, actually at my job a co-worker just found exactly such a bug yesterday: Debug build zeroed out the variable and the release build didn't. So the bug only occurred in the release build, but could not be reproduced on the debug build where the developers work on. So in the end he found it because of the different compiler flags used for debug vs release builds at our work place.