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]

integer overflow detection


Hi,

I was wondering whether there is an easy way for a front end to detect
whether an integer overflow had occurred?  Currently the GNU Modula-2
front end will detect cardinal number and integer subrange out of bound
(during assignment, INC and DEC).  However it does not detect overflows
for these data types during arithmetic expressions.

I guess it is not particularly difficult to wrap front end '-', '+', '*'
with checks similar to those found here: http://www.fefe.de/intof.html
albeit with the cost of a significant code explosion.  Is it possible
for subsequent TREEs to be able to detect whether the carry bit has been
set (for non constant tree expressions) at runtime?

regards,
Gaius


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