Re: C Interpreter and sizeof operator



Christian Bau wrote:
In article <438ce9a7$0$11070$e4fe514c@xxxxxxxxxxxxxx>,
 Skarmander <invalid@xxxxxxxxxxxxxx> wrote:

You can try and fudge this in cases where the application cannot possibly trip over the wrong size, but it's tricky to do this without violating the standard, and in an interpreter it's very unlikely to be of any value. Just pick a constant size for integers (4 bytes happens to be a very common one).

So if I write

   long long i;
   char array [100];

   for (i = 0; i < 100; ++i) array [i] = i;

the compiler is free to use 1, 2, 3, 4 or any other number of bytes for i, because it doesn't make any difference to the code. The compiler is allowed to cheat, as long as you cannot detect that it cheats.

Yes. The compiler is even free not to use any bytes for i at all and emit a fully initialized array in the object file somewhere, if this is the only piece of code that assigns to 'array'.


Obviously, the burden is on the compiler writer to make sure these optimizations are always safe, but as long as programs have the required semantics, the standard couldn't care less.

S.
.



Relevant Pages

  • Re: The IMMEDIATE mess
    ... nothing extra from the data stack or return stack and leaves nothing ... anything in allocated space that an unrelated standard program would ... routine actually executes DUP. ... The text interpreter is usually pretty ...
    (comp.lang.forth)
  • Re: Empty Search Order vs Search Empty Wordlist
    ... Some suggest there should be a standard way to hack into the interpreter ... It's a string of characters that represent a character literal. ...
    (comp.lang.forth)
  • Re: Mercurial 0.4b vs git patchbomb benchmark (/usr/bin/env again)
    ... There are a very few systems where env isn't in /usr/bin, ... live in whatever place you think of as "standard". ... Even if some interpreter IS where you think it should be, ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: GCC bitfield packing
    ... order in the standard? ... fundamental point of disagreement is about how big that trade-off is. ... support for standardization of a proposed feature, ... For a compiler writer, the only burden you should feel when the ...
    (comp.std.c)
  • Re: Python with Ecmascript
    ... compliant, I need to embbed Ecmascriptinterpreter - I ... need to execute plugins written in this language. ... What standard are you hoping to comply with? ...
    (comp.lang.python)