Re: Checking size of variables

Hans-Peter Diettrich <>
18 May 2005 00:49:53 -0400

          From comp.compilers

Related articles
Checking size of variables (Thomas Christensen) (2005-05-16)
Re: Checking size of variables (Karsten Nyblad) (2005-05-18)
Re: Checking size of variables (Hans-Peter Diettrich) (2005-05-18)
Re: Checking size of variables (2005-05-18)
Re: Checking size of variables (2005-05-18)
Re: Checking size of variables (Peter \Firefly\Lund) (2005-08-07)
| List of all articles for this month |

From: Hans-Peter Diettrich <>
Newsgroups: comp.compilers
Date: 18 May 2005 00:49:53 -0400
Organization: Compilers Central
References: 05-05-149
Keywords: errors
Posted-Date: 18 May 2005 00:49:53 EDT

Thomas Christensen wrote:

> Where does a compiler _usually_ perform checks on the size of
> integers and strings ?
> For example. If a user declares a variable as an "int" in the source
> code, and assigns it some 50 digit number (or any number, exceeding
> the size of an int).
> Is this sort of error detected by the lexer or by the type checker, or ?

In your example, the sizeof(int) can differ for every target machine.
That's why such checks typically occur in the code generator, or in the
preceding optimizer. The optimizer can remove dead code, so that an
overflow or similar error detection in dead code is not required before
that stage, at least.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.