[PATCH] Document arithmetic overflow semantics

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Thu Feb 13 15:55:00 GMT 2003


    The issue is GCC's internal representations, which shouldn't suffer
    from the same issue of poorly defined languages.  Hence, if CSE sees
    "x = i++; i = x" it had better understand exactly what "i = i++" means
    at the RTL-level.  One might hope that the interpretation of RTL and
    TREEs are independent of the source language and target architecture.

I agree.  Which is why I'm in favor of adding flags to tree nodes that say
whether the operation:

(a) has undefined behavior
(b) has defined overflow behavior, documented for the tree node in question
(c) will trap on overflow.

Then each language sets the appropriate bit for each expression it
makes (possibly defaulting to those from the types) and we do our best
to honor them.



More information about the Gcc-patches mailing list