Suspect "uninitialised value(s)" error
Karl Robillard via Valgrind-users <[email protected]> Wed, 11 Oct 2023 17:47:12 -0400
| Newsgroups | gmane.comp.debugging.valgrind |
|---|---|
| Message-ID | <[email protected]> |
I'm getting the following error on struct members which should absolutely be
initialized:
Conditional jump or move depends on uninitialised value(s)
To begin investigating I did a memset of zero on the entire struct and the
error goes away. Now this C++ struct inherits another one and the error is
reported in C code expecting the base struct. If I only memset the base
struct the error is still reported, which should be impossible.
Code summary of the weirdness:
struct ListDrawState : public DrawState { ... };
extern "C" void draw_func(DrawState*);
ListDrawState ds;
memset(&ds, 0, sizeof(DrawState)); // Error in draw_func()
//memset(&ds, 0, sizeof(ListDrawState)); // No error in draw_func()
draw_func(&ds);
Here's what I'm using to compile and test:
gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
valgrind-3.21.0
I've tried to re-create the problem in a stand-alone test, but the error
doesn't happen there. If someone wants to look at the actual code I can
provide a GitHub URL.
-Karl