Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 20004
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Jens Kilian <jjk@acm.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 20004 depends on: Show dependency tree
Show dependency graph
Bug 20004 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-02-16 14:28 Opened: 2005-02-16 09:37
Output from "g++ -v":
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20)

Compile the following code using "g++ -S bug.c":
---8<---bug.c------------------------------------------8<---
struct Foo
{
  int __attribute__((regparm(3)))
    (*p)(int);
};
extern struct Foo *foo;
extern const struct Foo *bar;

int
baz(int i)
{
  return (foo->p)(i);
}

int
zip(int i)
{
  return (bar->p)(i);
}
---8<--------------------------------------------------8<---

The only difference between baz() and zip() is that baz() uses a "struct Foo *"
while zip() uses a "const struct Foo *".  However, in the generated assembler
code, baz() passes parameters in registers as requested, and zip() doesn't.

_Z3bazi:
        [...]
        movl    foo, %eax
        movl    (%eax), %edx
        movl    8(%ebp), %eax
        call    *%edx

_Z3zipi:
        [...]
        movl    bar, %eax
        pushl   8(%ebp)
        movl    (%eax), %eax
        call    *%eax

Note: This bug is specific to the C++ compiler; the C compiler does the right
thing.

------- Comment #1 From Andrew Pinski 2005-02-16 14:28 -------
Confirmed in 3.2.3 and 3.3.3 but fixed already in 3.4.0 but this is a
regression from 3.0.4.

------- Comment #2 From Gabriel Dos Reis 2005-04-30 14:42 -------
won't fix for 3.3.6.  Works in 3.4.0 and higher.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug