Warning: `z' is used uninitialized in this function

Roberto Bagnara bagnara@cs.unipr.it
Thu Oct 11 16:10:00 GMT 2007


Just to make sure before I submit a bug report: when GCC says that
a certain variable _is_ (as opposed to _may be_) used uninitialized
in this function, it means that it has proved that the variable
is indeed used uninitialized, right?

I am asking because I have a testcase where g++ gives this warning for
`z' in the statement marked with (***) below.  However, `z' is indeed
initialized by the mul() function template, which takes the first
argument by (non-const) reference:

template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
inline Result
add_mul_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
   Type z;
   Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
   switch (r) {
   case V_NEG_OVERFLOW:
   case V_LT:
     if (to <= 0) {
       to = z;  (***)
       return r;
     }

All the best,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it



More information about the Gcc mailing list