Save/Store information, which variable are not initialized
Sławomir Lach
slawek@lach.art.pl
Fri Mar 4 16:06:56 GMT 2022
I known, IDE will detect cases, whereas variable is not initialized, but some
developers still have problems with variable initialization.
I suppose gcc do not support any run-time sanitizer, because I do not found
any information.
So: gcc will introduce hidden array of variables for each context. One bit
stores information about one variable in current scope. So, if it is set -
variable was initialized. In other case, variable is not initialized. When new
scope is created, gcc will allocate this array and set each element to 0. When
program set variable, also bit is set.
Each structure will contains this array at top of self. GCC must hack access
to this struct in some way. That is big problem to handle this case, because
some languages allow to free memory access. Maybe for struct store information
about fields state in different part of memory?
Idea was inspired by way to detect cases, where return address was written.
Programmer should compile program with special switch to enable this mode.
GDB could support this feature of gcc and read, which variable was not set.
More information about the Gcc
mailing list