Bug 12236 - [3.3/3.4 Regression] regparm and fastcall messes up parameters
Summary: [3.3/3.4 Regression] regparm and fastcall messes up parameters
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P1 critical
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 12270 (view as bug list)
Depends on: 12344
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-10 09:53 UTC by lightspeed
Modified: 2004-01-17 04:22 UTC (History)
4 users (show)

See Also:
Host:
Target: i686-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-09-10 15:44:56


Attachments
the preprocessor output of a file reproducing the bug (3.87 KB, text/plain)
2003-09-10 09:55 UTC, lightspeed
Details
the original cpp file (it's easier to understand) (310 bytes, text/plain)
2003-09-10 09:55 UTC, lightspeed
Details
minimized testcase (220 bytes, text/plain)
2003-09-15 23:07 UTC, janis187
Details

Note You need to log in before you can comment on or make changes to this bug.
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 1 lightspeed 2003-09-10 09:55:07 UTC
Created attachment 4734 [details]
the preprocessor output of a file reproducing the bug
Comment 2 lightspeed 2003-09-10 09:55:39 UTC
Created attachment 4735 [details]
the original cpp file (it's easier to understand)
Comment 3 Andrew 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 5 janis187 2003-09-15 23:07:57 UTC
Created attachment 4763 [details]
minimized testcase
Comment 6 Andrew 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.