This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
On Wed, 21 Jan 2009, Richard Guenther wrote:
> If it has automatic storage duration, do C or C++ require that automatic
> variables have distinct locations? Thus, is this bug invalid? (Of course
> both automatic variables have overlapping lifetime)
>
> So, can a compiler assign the same memory to i and j in
>
> int i, j;
> i = 0;
> j = 0;
> return i + j;
i and j are distinct objects so must have addresses that do not compare
equal (if the addresses are taken so pointers to both objects are compared
at a time when both pointers are valid). This applies to any two
automatic variables with overlapping lifetimes (but once an object's
lifetime has ended, any further use of a pointer to it is undefined
behavior).
--
Joseph S. Myers
joseph@codesourcery.com
- References:
- [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615
- Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615