valgrind "uninitialized value" for __cxa_begin_catch? (Only if -static)

Benjamin Redelings benjamin_redelings@ncsu.edu
Tue Mar 25 21:43:00 GMT 2008


Hi,

I have noticed that, when I link my code statically, valgrind complains 
about every exception that is caught.  In the example code below, the 
error is:
==32195== Conditional jump or move depends on uninitialised value(s)
==32195==    at 0x44B8A4: __cxa_begin_catch (in 
/home/bredelings/Devel/Sampler/Runs/test)
==32195==    by 0x400361: main (in 
/home/bredelings/Devel/Sampler/Runs/test)
If I link my code dynamically, this does not happen.

Question: Is this a real problem?  Or, is it safe to ignore this warning?

--------------Example code (test.C) ----------------

#include <iostream>

int main(int argc, char* argv[])
{
 std::cout<<"argc = "<<argc<<"\n";
 try {
   if (argc > 3) {
     throw int(2);
   }
 }
 catch (int i) {
   std::cout<<"caught exception = "<<i<<"\n";
 }
 exit(0);
}

---------------------Example code---------------------

Kernel: AMD64 Linux 2.6.24 (Debian unstable)
GLibc: 2.7
GCC: 4.1, 4.2 and 4.3
        4.0 does not have this problem.

compilation command:
% gcc test.C -o test -static

execution command:
% ./test 1 2 3 4 5

thanks!

-BenRI



More information about the Gcc mailing list