This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
C++: No Warning for passing value > 255 as parameter to a function requiring "unsigned char"
- From: Martin Wodok <m dot wodok at osb-ag dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 22 Jul 2005 15:51:02 +0200
- Subject: C++: No Warning for passing value > 255 as parameter to a function requiring "unsigned char"
Hi,
I'm compiling with "gcc (GCC) 4.0.1 (Debian 4.0.1-2)" and have the following
problem: I don't manage to get a warning for the following code
void anyFunction (unsigned char var)
{
printf ("anyFunction's var: %d\n", var); fflush(0);
}
int main()
{
unsigned char var = 1000;
printf ("main's var: %d\n", var); fflush(0);
anyFunction (1000);
}
Assigning 1000 is of course out of bounds for "unsigned char", thus the
correct output, which I do get, is:
main's var: 232
anyFunction's var: 232
My parameters to enable warnings are:
-Wall -Winline -Wshadow -Woverloaded-virtual -W -Wconversion -Wpointer-arith
Do I miss some warning-parameters that I can use to get a warning for the
above code? I haven't found any yet...
Many thanks in advance!
Greetings from Munich,
Martin Wodok
--
Dipl.-Inf. Martin Wodok
OSB AG Ingenieur- und IT-Dienstleistungen
Klenzestraße 38
80469 München
Telefon: ?+49 (0)89/23 88 57-48
Telefax: ?+49 (0)89/23 88 57-40