Possible Duplicate:
Can I make GCC warn on passing too-wide types to functions?
Is there a way to make gcc or g++ produce a warning when I pass a signed int to a function that takes an unsigned int?
For instance:
int main(){
char buf[8];
int i;
for(i=0;i<6;i++)
buf[i] = 'a';
buf[6]='\0';
strcat(buf, " ");
strncat(buf, "happystacksmashingstring",-1 );
return 0;
}
will cause stack smashing because strncat takes a size_t as its third argument, which is often an unsigned int. Yet, the command:
g++ -Wall -Wextra -Werror -pedantic -W -Weffc++ -Wconversion test.c
which contains every warning flag I know, produces no errors or warnings at compile time, and a smashed stack at runtime.
gcc -Wall -Wextra -Werror -pedantic -W -Wconversion test.c
will produce errors about the implicit conversions in contrast. Why doesn't the -Wconversion flag work properly with g++?