C Interpreter and sizeof operator



If one were writing a C interpreter, is there anything in the standard
standard that requires the sizeof operator to yield the same value for
two different variables of the same type?

Let's assume that the interpreter does conform to the range values
for, say, type int, but allocates storage for the variables based
on their value. So, for two variables foo and bar

int foo = 0; /* interpreter allocates two bytes */
int bar = 200000000; /* interpreter allocates four bytes */

Does the standard require that sizeof foo == sizeof bar thereby
making this allocation scheme broken, unless hidden in some way?
Or is it perfectly acceptable for the sizeof operator to different
results?

Regards, Oz
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.



Relevant Pages

  • Re: Find the size of a datatype
    ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... of course without using sizeof operator. ... standard will tell you how big an int is. ...
    (comp.lang.c)
  • Re: C Interpreter and sizeof operator
    ... > If one were writing a C interpreter, is there anything in the standard ... for two variables foo and bar ... > Or is it perfectly acceptable for the sizeof operator to different ...
    (comp.lang.c)
  • Re: Find the size of a datatype
    ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... course without using sizeof operator. ... standard will tell you how big an int is. ...
    (comp.lang.c)
  • Re: The act of sizeof(++i) ?
    ... It is the C++ standard. ... > Frederick Ding wrote: ... The operand is either an expression, ... > sizeof operator does not evaluate the expression. ...
    (microsoft.public.vc.language)