Can the address of a variable change during a function?

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Nov 20 12:05:16 AEST 1988


In article <6472 at june.cs.washington.edu> pardo at cs.washington.edu (David Keppel) writes:
>I can imagine, however implementations in which the address
>of a variable is not constant throughout the function (see below).

The cases where this would be permissible are so rare as to make it
practically certain no compiler implementor would bother to do so.

You may safely write your code as though storage for a variable does
not move during its lifetime (except through an explicit realloc()).
Automatic variables do go out of scope upon exit from the block that
defines them, but they don't move around within the duration of the
block.

>In this case, the behavior of the program will be *very*
>different than if the variables had been declared with
>	    auto int i;
>	    int j;

No, the "auto" was implicit in the previous example.  In fact there
is no real use for an explicit "auto" keyword in C.

>I also belive that 'auto' has been removed from dpANS C.

No, it's listed as a storage class specifier in section 3.5.1.
Where do you get these strange beliefs?



More information about the Comp.std.c mailing list