This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17564] New: [4.0 Regression] New treatment of function pointers when used with equality operators
- From: "danglin 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 Sep 2004 23:19:34 -0000
- Subject: [Bug c/17564] New: [4.0 Regression] New treatment of function pointers when used with equality operators
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
As a GCC extension, GCC allows the comparison of a function pointer and
a void pointer. Previous versions of GCC didn't canonicalize the function
pointer when it was compared with a void pointer. Unfortunately, there
doesn't appear to be any documentation on when canonicalization is
performed.
Now GCC canonicalizes the function pointer when compared with a void
pointer. It even does so when the function pointer is cast to a void
pointer. The following program demonstrates the problem:
void *f (void) __attribute__ ((__noinline__));
void *
f (void)
{
return f;
}
int
main (void)
{
if (f () != f)
abort ();
exit (0);
}
000105b4 <main>:
105b4: 6b c2 3f d9 stw rp,-14(,sp)
105b8: e8 5f 1f d5 b,l 105a8 <f>,rp
105bc: 6f c4 01 00 stw,ma r4,80(,sp)
105c0: 08 1c 02 44 copy ret0,r4
105c4: 23 88 10 00 ldil 10800,ret0
105c8: e8 40 00 60 b,l 10600 <__canonicalize_funcptr_for_compare>,r
p
105cc: 4b 9a 02 b0 ldw 158(,ret0),r26
105d0: 80 9c 20 0a cmpb,=,n ret0,r4,105dc <main+0x28>
105d4: e8 5f 1d 5d b,l 10488 <_end_init+0x24>,rp
The address of the function descriptor for f is passed to
__canonicalize_funcptr_for_compare for canonicalization whereas the pointer
passed back from f as a void pointer is not canonicalized. The causes
the program to abort with the current 4.0 CVS source.
The change in function pointer canonicalization causes the testcase
for PR17377 to fail.
--
Summary: [4.0 Regression] New treatment of function pointers when
used with equality operators
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: danglin at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: hppa-unknown-linux-gnu
GCC host triplet: hppa-unknown-linux-gnu
GCC target triplet: hppa-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17564