This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10882: passing and return by reference of char pointer corrupted on x86_64
- From: aj at gcc dot gnu dot org
- To: dirkjan at magma-da dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 20 May 2003 13:07:52 -0000
- Subject: Re: c++/10882: passing and return by reference of char pointer corrupted on x86_64
- Reply-to: aj at gcc dot gnu dot org, dirkjan at magma-da dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: passing and return by reference of char pointer corrupted on x86_64
State-Changed-From-To: open->closed
State-Changed-By: aj
State-Changed-When: Tue May 20 13:07:52 2003
State-Changed-Why:
The code is invalid, you do the following basically:
int number;
void *ptr;
ptr = &number;
*ptr = NULL;
Note that int is 32-bit and a pointer is 64-bit on x86-64.
You therefore override some random memory, in this case
the string popped_name.
Since your code is not 64-bit clean, and you explicitly
shut GCC up with casts to void, there's not much that GCC can do and it will produce this code.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10882