Re: C++: No Warning for passing value > 255 as parameter to a function requiring "unsigned char"

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

 



Hi Gaby
hi Eljay,

thanks for your answer!

> Martin Wodok <m.wodok@xxxxxxxxx> writes:
> | Assigning 1000 is of course out of bounds for "unsigned char", thus the
>
> No, it is not.  Unsigned integer types are modulo types; it is no overflow.

Yes, they're modulo types, that's why this is NOT an error, but I still think 
that should be a WARNING. There're compilers like Tasking that throw a 
warning out on that one, so I'm really searching for a way to enable a 
warning for that one (maybe something like the warning -Wconversion), and not 
some extra code (Eljay, thanks anyway!!), because it should work on existing 
code and I don't want to get code-explosion (we're working embedded) just 
because some range-check that could be done by the compiler...

So it seems there's really no way for GCC to warn here?

Thanks again Gaby and Eljay,
/\/\artin

-- 
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


[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