G++/GCC not detetcing stupid errors in code.
Laurent Dufrechou
laurent.dufrechou@free.fr
Thu May 22 10:53:00 GMT 2008
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@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] De la
part de Sven Eschenberg
Envoyé : jeudi 22 mai 2008 10:57
À : Laurent Dufréchou
Cc : gcc-help@gcc.gnu.org
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,
>
> Im using g++ for the first time via gcc 4.1.2.
> Ive 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) doesnt 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, Im quite disappointed :/
> Ive 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
>
>
More information about the Gcc-help
mailing list