This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ no warning about uninitialized variables


One got to use

-O or -O1 as option to g++ -O0 will not do. By the way it is really limited to what extent the compiler can track down uninitialized variables.


Den 19-04-2013 13:07, David skrev:
I am using eclipse and gnu. (Maybe my version is to old.)
I have

struct MyStruct {
   int a0,a1;
};

void afunc(int &t) {
   cout<<"in para "<<t<<endl;
   t=5;
}

int main() {
  int a, b,c;
  MyStruct k;
  afunc(a);
  b=c+1;
  cout<<"b "<<b<<endl;
  afunc(b);
  k.a0=k.a1+a;
  cout<<"k.a0 "<<k.a0;
  afunc(k.a1);
}

As you can see a lot of uninitialized variables, but when I compile I
get no warnings. Here is the result of a compilisation:

**** Build of configuration Debug for project test ****

make all
Building file: ../src/test.cpp
Invoking: Cygwin C++ Compiler
g++ -D_CYGWIN -O0 -g3 -pedantic -Wall -c -fmessage-length=0 -MMD -MP
-MF"src/test.d" -MT"src/test.d" -o"src/test.o" "../src/test.cpp"
Finished building: ../src/test.cpp

Building target: test.exe
Invoking: Cygwin C++ Linker
g++  -o"test.exe"  ./src/test.o
Finished building target: test.exe

Why don't I get a warning?







--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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