g++ no warning about uninitialized variables
marco atzeri
marco.atzeri@gmail.com
Sat Apr 20 20:29:00 GMT 2013
On 4/19/2013 1:07 PM, David wrote:
> 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?
>
likely your makefile is swallowing the output.
g++ -Wall -pedantic prova.cpp -o prova
prova.cpp: In function ‘int main()’:
prova.cpp:18:8: warning: ‘c’ is used uninitialized in this function
--
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
More information about the Cygwin
mailing list