12236 – [3.3/3.4 Regression] regparm and fastcall messes up parameters (original) (raw)

Description lightspeed 2003-09-10 09:53:29 UTC

The bug is that function buggycall gets its parameters heavily messed up!! All functions should output its parameters' values like 1,2,3,4. Functions buggycall2 and buggycall3 output "1,2,3,4" as they should, but function buggycall outputs "4 0 1097054101 134513542" that is NOT what got passed to it. This looks like a parameter passing error, and as you can see from the source file it only occurs when I don't declare a prototype for the function and I put the calling convention after the return type. Putting the calling convention before the return type solves the problem, but then my program doesn't compiles with MSVC++, cause it is a violation of its syntax(I guess). This bug occurs both with gcc and g++. This bug occurs in mingw32 too.

Comment 3 Drea Pinski 2003-09-10 15:44:56 UTC

I can confirm this on the mainline (20030909). It is a regression from at least 3.0.4 where it worked. Also it works in C so it looks like a C++ bug.

Comment 4 janis187 2003-09-15 23:05:59 UTC

The regression in PR 12236 was introduced or exposed with this patch:

http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00774.html

--- gcc/gcc/ChangeLog ---

2001-09-21 Joseph S. Myers <jsm28@cam.ac.uk>

    Table-driven attributes.
    * c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
    [lots more]

--- gcc/gcc/cp/ChangeLog ---

2001-09-21 Joseph S. Myers <jsm28@cam.ac.uk>

    Table-driven attributes.
    * decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
    [lots more]

The regression hunt took place on i686-pc-linux-gnu using the test case from comment #1, which was linked and run with a comparison of the output against expected output.

NOTE: This patch was added at 2001-09-21 01:26:54 UTC; until 07:17:49 that day, cc1plus could only be built with GCC 3.x.

Comment 6 Drea Pinski 2003-09-17 06:05:20 UTC

*** Bug 12270 has been marked as a duplicate of this bug. ***

Comment 7 Joseph S. Myers 2003-10-06 21:28:13 UTC

The patch in PR 12344 seems to fix this bug as well.

Comment 8 Mark Mitchell 2003-10-07 07:10:18 UTC

Fixed in GCC 3.3.2 and GCC 3.4.