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]

 



----- Original Message ----- 
From: "Gabriel Dos Reis"

> |
> | > 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,
>
> The argument was that it makes sense to issue a warning when the the
> code is dubious -- not just an error.  However, in this case, modulo
> arithmetic for unsigned int is a characteristic propery.
> Consequently, it does not make much sense to warn about it.
>

Yet gcc (as distinct from g++) does issue a warning about this. At least
that's the case for me with versions 3.2.2 and 3.4.4. Is that an instance of
gcc doing something that doesn't make much sense ?

That's not a rhetorical question, btw. I anticipate that your answer is
"yes" - but faik there may well be mitigating circumstances that I'm unaware
of.

Cheers,
Rob


[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