public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* C++: No Warning for passing value > 255 as parameter to a function requiring "unsigned char"
@ 2005-07-22 13:51 Martin Wodok
  2005-07-22 14:47 ` Gabriel Dos Reis
  2005-07-22 15:22 ` Eljay Love-Jensen
  0 siblings, 2 replies; 8+ messages in thread
From: Martin Wodok @ 2005-07-22 13:51 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-27  0:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 13:51 C++: No Warning for passing value > 255 as parameter to a function requiring "unsigned char" Martin Wodok
2005-07-22 14:47 ` Gabriel Dos Reis
2005-07-26  9:36   ` Martin Wodok
2005-07-26 14:28     ` Eljay Love-Jensen
2005-07-26 21:54     ` Gabriel Dos Reis
2005-07-27  0:44       ` Sisyphus
2005-07-22 15:22 ` Eljay Love-Jensen
2005-07-22 15:24   ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).