This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/28073] Type-punned pointer passed as function parameter generates bad assembly sequence
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jun 2006 16:54:46 -0000
- Subject: [Bug c/28073] Type-punned pointer passed as function parameter generates bad assembly sequence
- References: <bug-28073-12847@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-06-19 16:54 -------
(In reply to comment #2)
> Changing just one line of the test program to the (AFAIK) legal C code. By
> casting through void *, we are addressing Andrew's concerns about violating the
> C rules.
>
> Foo *pFoo = *(Foo **) ((void *)&longPtr); /* // BAD! */
No you are still accessing a long as a "Foo*", the intermediate types does not
change a thing.
The cast to "void*" is designed to get rid of the warning but does not get rid
of the undefinedness of the code.
*** This bug has been marked as a duplicate of 21920 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28073