Skip to main content
gamedev.net
🔒 Locked

'pre-initialized' values

Started by osh 1 reply 300+ views
Original Post
osh
osh
Hi! Imagine you have a class with few variables. When you call a constructor, these variable are pre-initialized with some values (bool - 204, ptr to anything - 0xcdcdcdcd). I'd like to know, if these values are random, or compiler dependent or what? I need to know whether I can say - in cross-platform project - that uninitialized variable have such and such value. Cheers Andrew
SiCrane
SiCrane
Compiler dependent, and compile flag dependent. You're probably using MSVC. MSVC in debug mode will set certain bit patterns for uninitialized and freed memory. In release mode it doesn't do it. I don't think gcc does anything like it. Borland compilers might, but it's been a while since I've used any of them.
Nemesis2k2
Nemesis2k2
Those values are only written there when you're compiling a program in debug more. They're written by the memory manager, and they are compiler dependant. In release mode, those values could be anything.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.