This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Do C++ signed types have modulo semantics?
Mark Mitchell <mark@codesourcery.com> writes:
| Michael Veksler wrote:
|
| >> Most programmers "know" that arithmetic is modulo wordsize. And those few
| >>who know the right answer (only unsigned arithmetic is modulo) will
| >>from time to time slip up and omit the "unsigned" keyword in their
| >>declarations.
|
| I agree.
|
| Although the standard clearly makes signed overflow undefined, I think
| it would be better if GCC defined it to be modulo arithmetic. The
| degree to which that would result in inferior code seems likely to be
| somewhat small, and the amount of user confusion we would eliminate,
| and the number of programs that would not break with GCC, even though
| they work with other compilers, seems likely to be high.
Amen.
-- Gaby