Summary: | attribute on member function pointer have no effect | ||
---|---|---|---|
Product: | gcc | Reporter: | Ulrich Drepper <drepper.fsp> |
Component: | c++ | Assignee: | Jason Merrill <jason> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | boaz, bruce_pedersen, ehrhardt, fang, gcc-bugs, jacek, massimiliano.ghilardi, pmike2001, techrazy.yang, wbrana |
Priority: | P3 | Keywords: | wrong-code |
Version: | 3.2.1 | ||
Target Milestone: | 4.4.3 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2009-11-06 04:56:44 | |
Attachments: |
e.cc
The testcase fail g++ 4.3.0 |
Description
Ulrich Drepper
2003-01-21 04:56:00 UTC
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> To: drepper@redhat.com Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/9381: stdcall attribute ignored in member function pointer type Date: Tue, 21 Jan 2003 15:10:30 +0100 On Tue, Jan 21, 2003 at 04:52:51AM -0000, drepper@redhat.com wrote: > The attached file is miscompiled since the stdcall attribute is ignored in the fp type definition. The result it that in the function bar the parameters are popped from the stack even though they have already been removed by the called fucntion (f1 in this case). The answer to this non bug used to be: "The placement of your __attribute__ is wrong". This should be the proper placement: typedef int (__attribute__ ((stdcall)) foo::*fp)(int); However, with the new parser this gives a parse error :-( The following gives a warning with 3.4 but works with all gcc versions, it is documented as an extension though: typedef int (foo::*__attribute__ ((stdcall)) fp) (int); I.e. this is not a bug in 3.2.1. It is a bug in the new parser in 3.4 though. regards Christian -- THAT'S ALL FOLKS! State-Changed-From-To: open->analyzed State-Changed-Why: Christian already analyzed this Already fixed in 3.4: pushl %ebx ..... ..... call *%edx addl $8, %esp popl %ebx ret The code is wrong now, I should of said that. *** Bug 11893 has been marked as a duplicate of this bug. *** Not a regression any more. I do get a warning now, saying this attribute only applies to function pointers. *** Bug 29911 has been marked as a duplicate of this bug. *** *** Bug 34468 has been marked as a duplicate of this bug. *** (In reply to comment #1) > From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> > To: drepper@redhat.com > Cc: gcc-gnats@gcc.gnu.org > Subject: Re: c++/9381: stdcall attribute ignored in member function pointer type > Date: Tue, 21 Jan 2003 15:10:30 +0100 > > On Tue, Jan 21, 2003 at 04:52:51AM -0000, drepper@redhat.com wrote: > > The attached file is miscompiled since the stdcall attribute is ignored in the fp type definition. The result it that in the function bar the parameters are popped from the stack even though they have already been removed by the called fucntion (f1 in this case). > > The answer to this non bug used to be: "The placement of your __attribute__ > is wrong". This should be the proper placement: > > typedef int (__attribute__ ((stdcall)) foo::*fp)(int); > > However, with the new parser this gives a parse error :-( > The following gives a warning with 3.4 but works with all gcc versions, it > is documented as an extension though: > > typedef int (foo::*__attribute__ ((stdcall)) fp) (int); I am afraid, but this did not work in gcc 4.3.0, now. I add this, but still failed with a SIGFAULT... I attach my litter test case file, please try to compile it with g++ 4.3.0, and it will fail... Created attachment 15898 [details] The testcase fail g++ 4.3.0 From this bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893, we know the typeof operator make all things correctly. But in gcc 4.3.0, this operator failed, too. (In reply to comment #6) > Not a regression any more. It is a regression now. It worked in 3.4 and doesn't work in 4.x. That's why I'm still using GCC 3.4.6. Subject: Bug 9381 Author: jason Date: Fri Nov 6 21:18:35 2009 New Revision: 153977 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153977 Log: PR c++/9381 * decl2.c (build_memfn_type): Preserve attributes. (cp_reconstruct_complex_type): Likewise. (maybe_retrofit_in_chrg): Likewise. * call.c (standard_conversion): Use build_memfn_type. * pt.c (tsubst): Likewise. * decl.c (build_ptrmem_type): Likewise (check_function_type): Preserve attributes. * tree.c (cp_build_type_attribute_variant): Propagate exception specs on METHOD_TYPE, too. (strip_typedefs): Preserve exception specs and attributes. Added: trunk/gcc/testsuite/g++.dg/abi/regparm1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/class.c trunk/gcc/cp/decl.c trunk/gcc/cp/decl2.c trunk/gcc/cp/pt.c trunk/gcc/cp/tree.c trunk/gcc/testsuite/ChangeLog Subject: Bug 9381 Author: jason Date: Sat Nov 7 19:45:56 2009 New Revision: 153998 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153998 Log: PR c++/9381 * decl2.c (build_memfn_type): Preserve attributes. * tree.c (canonical_type_variant): Likewise. * call.c (standard_conversion): Use build_memfn_type. * pt.c (tsubst): Likewise. * decl.c (build_ptrmem_type): Likewise Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/abi/regparm1.C Modified: branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/call.c branches/gcc-4_4-branch/gcc/cp/decl.c branches/gcc-4_4-branch/gcc/cp/decl2.c branches/gcc-4_4-branch/gcc/cp/pt.c branches/gcc-4_4-branch/gcc/cp/tree.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog Fixed for 4.4.3. The patch for 4.4 applied fine to 4.3, but didn't fix the bug there for some reason. |