This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
integer overflow detection
- From: Gaius Mulley <gaius at glam dot ac dot uk>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 27 Apr 2011 13:03:30 +0100
- Subject: 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