Finding uninitialized storage errors in C++
TEST
run-time and STORAGE
options.
In the following example: TEST STORAGE(FD,FB,F9)
the
first subparameter of STORAGE
is the fill byte for
storage allocated from the heap. For example, storage allocated through
operator new
is filled with the byte 0xFD
.
If you see this byte repeated throughout storage, it is likely uninitialized
heap storage.The second subparameter of STORAGE
is the fill
byte for storage allocated from the heap but then freed. For example,
storage freed by the operator delete
might be filled
with the byte 0xFB
. If you see this byte repeated
throughout storage, it is likely storage that was allocated on the
heap, but has been freed.
The third subparameter of STORAGE
is the fill
byte for auto storage variables in a new stack frame. If you see
this byte repeated throughout storage, you probably have uninitialized
auto storage.
The values chosen in the example are odd and large, to maximize early problem detection. For example, if you attempt to branch to an odd address, you will get an exception immediately.
STORAGE
run-time
option as STORAGE(FD,FB,F9)
, to the line labeled
PUSHPOP2 and issue the command: LIST *ptr ;
You
will see the byte fill for uninitialized heap storage as the following
example shows: LIST * ptr ;
(* ptr).next = 0xFDFDFDFD
(* ptr).i = -33686019
Refer to the following topics for more information related to the material discussed in this topic.
- Related references
- z/OS® Language Environment Programming Guide