This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Do C++ signed types have modulo semantics?


On Tuesday 28 June 2005 12:07, Robert Dewar wrote:
> Mark Mitchell wrote:
> > 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.
>
> I find this reasonable, especially given the general attitude that
> we don't care much if gcc programs are not easily portable to other
> compilers, which is always the strongest argument against this kind
> of language extension (defining the undefined).
>
> I would prefer to make such a decision with data about the impact
> on code quality, rather than Mark's "seem likely" guess.

Indeed.  Frankly this "seems likely" guess confuses me.  It is already
well known that using unsigned types for loop counters may greatly
improve the code gcc can generate for loops.  With wrap-around semantics,
suddenly countable loops are turned into noncountable loops, overflow
can occur, dependencies may be introduced that never happen in reality,
and so on.

Anyway, I've started a SPEC run with "-O2" vs. "-O2 -fwrapv".  Let's see
how big the damage would be ;-)

Gr.
Steven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]