RE: G++/GCC not detetcing stupid errors in code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Arf no... Here is my compile option :)

g++ -march=nocona -Wall -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-align
-Wcast-qual -Wconversion -Wextra -Wreorder -Wold-style-cast -Winit-self
-pedantic -Wreturn-type -Wunreachable-code -D REENTRANT -D_GNU_SOURCE test.c
-o test

> Implicit conversion are a nice thing to have ;-).
Yeah sure , but I prefer the secure way ;)


-----Message d'origine-----
De : gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] De la
part de Sven Eschenberg
Envoyé : jeudi 22 mai 2008 10:57
À : Laurent Dufréchou
Cc : gcc-help@xxxxxxxxxxx
Objet : Re: G++/GCC not detetcing stupid errors in code.

You are looking for -Wconversion I guess.

Implicit conversion are a nice thing to have ;-).

Regards

-Sven


Laurent Dufréchou schrieb:
> Hi there,
>
> I?m using g++ for the first time via gcc 4.1.2.
> I?ve written a little code (first C++ oriented and because guys with which
I
> work come from C, it is slightly modified to compile with G++ and gcc)
>
>   
>>>>>>>>>>>>>>>>>>>> Code >>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>                                         
>  
> //#include <iostream>
> #include <stdio.h>
>
> //using namespace std;
>
> int main()
>
> {
>
>                 int toto;
>
>                 short tata;
>
>                 toto = 1111118;
>
>                 tata = toto;  //error 1!
>
>                 //cout << toto << "tata:" << tata << endl;
>
>                 printf("%d %i",toto,tata);
>
>                 //return 0; //error 2 because no return
>
> }
>
>   
>
> I i compile with gcc (cc), it detects no int returned error (OK good
point)
> But the downcast (tata = toto) doesn?t raise any warning!
>
> If I use G++ the downcast is not detected and even more the return is not
> also detected (!)
>
> I was thining that Gcc was really strict and I choose it because I was
> thinking that, I?m quite disappointed :/
> I?ve tried ?Wall ?Wextra ?pedantic + a ton of other switch with no luck?
>
> Do i miss something ? 
>
> How can I put Gcc in ?user is stupid I need to check all? mode?
>
>
> Laurent
>
>   




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux