From: <no...@so...> - 2002-05-26 10:06:56
|
Bugs item #414799, was opened at 2001-04-09 16:22 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=414799&group_id=2435 Category: gcc Group: None >Status: Closed Resolution: Fixed Priority: 5 Submitted By: TAMURA Kent (tkent) Assigned to: Nobody/Anonymous (nobody) Summary: __stdcall and typedef Initial Comment: Environment: gcc-2.95.2-3 Windows 2000 In the following case, __stdcall for TIMECALLBACK1 is ignored. callback.cpp ------------------------------------- typedef void (__stdcall TIMECALLBACK1)(int,int); typedef void __stdcall (TIMECALLBACK2)(int,int); void callFoo(TIMECALLBACK1* callback1, TIMECALLBACK2* callback2) { int i; for (i = 0; i < 1000; i++) { (*callback1)(1, 2); } for (i = 0; i < 1000; i++) { (*callback2)(1, 2); } } -------------------------------------------------- With "g++ -O2 -S callback.cpp" I got the following: ------------------------------------------ L6: addl $-8,%esp pushl $2 pushl $1 call *%esi addl $16,%esp ;****** <- Problem decl %ebx jns L6 movl $999,%ebx .p2align 4,,7 L11: addl $-8,%esp pushl $2 pushl $1 call *%edi addl $8,%esp ;****** decl %ebx jns L11 leal -24(%ebp),%esp ------------------------------------------- Calls for `callback1' is not compiled as __stdcall. It must be the same as calls for `callback2'. Workarounds are: - Use C. This problem occurs only in C++. - Move the position of __stdcall like TIMECALLBACK2. But w32api has many typedefs like TIMECALLBACK1. ---------------------------------------------------------------------- Comment By: Luke Dunstan (infidel) Date: 2002-05-23 01:02 Message: Logged In: YES user_id=30442 Yes, this is fixed in GCC 3.1. ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2001-10-12 16:11 Message: Logged In: YES user_id=11494 Bad news: with 3.0.2 (prerelease) the bug is still there. Good news: with trunk CVS it is fixed. This uses a table- driven approach to attributes. g++ -S callback.cpp L5: subl $8, %esp pushl $2 pushl $1 movl 8(%ebp), %eax call *%eax addl $8, %esp <<<<<< leal -4(%ebp), %eax incl (%eax) jmp L2 <snip> L9: subl $8, %esp pushl $2 pushl $1 movl 12(%ebp), %eax call *%eax addl $8, %esp <<<<<< leal -4(%ebp), %eax incl (%eax) jmp L6 L1: ---------------------------------------------------------------------- Comment By: TAMURA Kent (tkent) Date: 2001-06-21 16:32 Message: Logged In: YES user_id=163353 gcc-2.95.3-4 in mingw-1.0-20010608 reproduces this problem. ---------------------------------------------------------------------- Comment By: TAMURA Kent (tkent) Date: 2001-04-13 13:58 Message: Logged In: YES user_id=163353 That patch did not fix this problem. ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2001-04-09 20:43 Message: Logged In: YES user_id=11494 This bug is fixed by the following patch: C++ parser bug with function attributes: http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01751.html The patch is incorporated in cygwin gcc-2.95.3-2 source distro. Danny ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=414799&group_id=2435 |