This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

spurious warning 'might be used uninitialized' with egcs 1.1.2


Hello,

Compiling the following program with -g -O2 -Wall generates a
warning. I think egcs should not complain since the 'strange' variable
is initialized during the declaration.

This occurred to me using egcs 1.1.2 on a Pentium under Linux
2.2.2. Here is a compilation example :

(lurien) luc% g++ --version
egcs-2.91.66
(lurien) luc% g++ -c -g -O2 -Wall uninit.cc
uninit.cc: In method `int A::fa(int, char **)':
uninit.cc:21: warning: `int strange' might be used uninitialized in this function
(lurien) luc% 



--------------- uninit.cc ---------------
class C
{ int l_;
  public :
   C ();
  ~C ();
  int fc () const { return l_; }
};

class B { public : int fb (); };

class A { B b; public : int fa (int  argc, char** argv); };

int A::fa (int argc, char** argv)
{
  while (argc > 1) {
    if (argv [0][1] != '\0') {
      char* ptr = argv [0];
      while (*++ptr) {
        C c1;
        if (ptr != 0) {
          int strange = b.fb ();
          if (strange)
            return strange;
          ptr += c1.fc ();
        }
        else
          C c2;
      }
    }
  }
  return 1;
}
--------------- uninit.cc ---------------



-- 
------------------------------------------------------------------------------
 Luc Maisonobe - DTS/MPI/MS/AM       |  Tel  : (33) 05-61-28-26-31
            CNES                     |  Fax  : (33) 05-61-27-35-40
     18 avenue E. Belin              |
 31401 Toulouse CEDEX 4 - FRANCE     |  Email: Luc.Maisonobe@cnes.fr
------------------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]