This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should GCC publish a general rule/warning due to it's defaultpresumption of undefined signed integer overflow semantics?
- From: Robert Dewar <dewar at adacore dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, 'gcc mailing list' <gcc at gcc dot gnu dot org>
- Date: Sat, 02 Jul 2005 12:46:56 -0400
- Subject: Re: Should GCC publish a general rule/warning due to it's defaultpresumption of undefined signed integer overflow semantics?
- References: <BEE9BCEE.AAC7%schlie@comcast.net> <20050630220250.GA10768@synopsys.com> <m3wtobwkg9.fsf@uniton.integrable-solutions.net> <20050630232531.GA11010@synopsys.com> <m3irzv5p1r.fsf@uniton.integrable-solutions.net> <a0222ee0d8b9c032e23bc30d2920559b@physics.uc.edu>
Andrew Pinski wrote:
But the reason question is why make it an undefined behavior instead of
an implementation defined? This would have made it clearer instead of
allowing the compiler not document what happens. Or is C++
just following C here? In which case it might be better to ask the C
committee why it was done this way and real definition of undefined for
this case?
Note that implementation defined in practice is a fairly severe
constraint. That's because you don't want to have a super complicated
definition that takes a book to describe all the horrible things
that might happen, so in practice you are pushed into some simple
decision (always traps, always saturates, always wraps etc for the
case of overflow).