c++/10882: passing and return by reference of char pointer corrupted on x86_64

aj@gcc.gnu.org aj@gcc.gnu.org
Tue May 20 13:21:00 GMT 2003


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



More information about the Gcc-bugs mailing list