3 Replies Latest reply on Oct 2, 2009 10:28 PM by nschmans

    Warning: Variable anon43 in <function name> might be used uninitialized

    nschmans

      when compiling with -O3, opencc issues warnings for unitialized variables, that look like this:

      Warning: Variable anon43 in <function name> might be used uninitialized

      where i've replaced the function name with <function name>.

      The problem is that 'anon43' is not a variable name in this function.  The compiler always names the variable in question 'anon##', where ## is some number.  So I have to play a guessing game as to which variable it refers to.  This is easy if the number of variables is small, but generally not.  Is there any way to discover which variable the compiler is complaining about?

        • Warning: Variable anon43 in <function name> might be used uninitialized
          dgilmore

          Let me check on this, hopefully I can get back with an answer somtime tomorrow.

          Doug

           

            • Warning: Variable anon43 in <function name> might be used uninitialized
              dgilmore

              Sorry for the delay in getting back, here is the information I have so far on this issue.

              It appears that there are problems in the optimizer phase in the Open64 compiler that detects uninitialized uses.
               
              I was surprised that the Pathscale compiler doesn't generate warning messages since the implementation in the Open64 and Pathscale compilers are the same.  But I found that unlike Open64, the Pathscale compiler does not pass -WOPT:warn_uninit=on flag to the back-end when -Wall is specified (unlike other warnings, the use of uninitialized variables messages are generated by the optimizer in both Open64 and in GCC).

              Until we fix this, you use "-Wall -WOPT:warn_uninit=off" to disable just these warnings.

              It's too bad this warning is too "noisy", since the algorithm does detect more cases than gcc:

              $ cat uninit1.c
              int sub(int x)
              {
                  int foo;

                  if (x) {
               foo = 2;
                  }
                  return foo != 0;
              }
              $ gcc -Wall -c uninit1.c  -O -S
              $ opencc -Wall -c uninit1.c  -O2
              "uninit1.c": Warning: Variable foo in sub might be used uninitialized
              $

              Unfortunately it is also noting situations that it shouldn't.

              BTW, the "anon*" variables are temporary variables that internally generated by the compiler.

              Again, sorry for the delay and thanks for posting.  During the investigation of this problem we uncovered several issues that we will need to address.

              Doug