On Wednesday 12 August 2015 15:58:36 Jeffrey Walton wrote: > The variable that is triggering the uninitialized access is a simple > flag and I believe it is initialized: > > bool g_flag = false; > > The C++ object that uses it is in another translation unit, and it has > a init_pritority attribute. > > I think I'm missing a finer detail on the confluence of the C++ > standard intersecting default initialization tricks in the BSS segment > taken modulo what Valgrind sees (or believes it sees). I *think* it > also has something to do with the double value initialization > discussed in > https://stackoverflow.com/questions/25742863/why-file-scope-static-variables-have-to-be-zero-initialized. > > Can someone help me understand what's going on?
It could be the initialzation order of the modules that causes the other translation unit to have its initializer run before g_flag is initialized. But g_flag should be initialized automatically by the compiler/linker before any code is run. There is another possibility: bool not_initialized; bool g_flag = false; int main(void) { g_flag = not_initialized; if(g_flag) printf("true"); else printf("false"); return 0; } The 'uninitializeness' is copied when memory is copied. Have you checked that this is not what is going on? /isj ------------------------------------------------------------------------------ _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users