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?
>>>>> "Nathan" == Nathan Sidwell <nathan@codesourcery.com> writes:
>> And all useful programs we write rely on undefined behaviour of
>> one sort or the other, starting with GCC. In the case of
Nathan> They do? I thought they usually relied on implementation
Nathan> defined, documented extensions or were part of the
Nathan> implementation. Now I'm sure you'll prove me wrong in some
Nathan> way or other, but please stick to the point -- do real
Nathan> important programs that must not break and cannot be changed
Nathan> rely on signed modulo behaviour?
I'm sure they do. Obviously they should not, since the standard says
not to. But most programmers are not language lawyers. 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.
So I can't point to a direct example but I am certain such examples
exist.
paul