This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29911] New: g++ calls to a regparm(3) pointer-to-member-function pass wrong arguments
- From: "massimiliano dot ghilardi at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Nov 2006 12:19:13 -0000
- Subject: [Bug c++/29911] New: g++ calls to a regparm(3) pointer-to-member-function pass wrong arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This is the second of 3 related g++ bugs concerning regparm(3) on ix86.
Problem: g++ 3.4.6, 4.0.4, 4.1.2 (and possibly others) pass wrong parameters
on calls to pointer-to-member-functions tagged __attribute((regparm(3))).
Test case:
--------------------------------------------------
// compile on ix86 with: g++ -Wall -O
extern "C" {
int printf(const char * format, ...);
}
class Base;
Base * save_this;
int * save_addr1, * save_addr2;
class Base {
public:
__attribute((regparm(3))) void set(int * addr1, int * addr2) {
if ((void *)this != (void *)save_this)
printf("error! this == %p, should be %p\n", this, save_this);
if (addr1 != save_addr1)
printf("error! addr1 == %p, should be %p\n", addr1, save_addr1);
if (addr2 != save_addr2)
printf("error! addr2 == %p, should be %p\n", addr2, save_addr1);
}
};
int main() {
void (__attribute((regparm(3))) Base::* pfm)(int *, int *) = &Base::set;
Base obj; save_this = &obj;
int x, y; save_addr1 = &x; save_addr2 = &y;
(obj.* pfm) (&x, &y);
return 0;
}
--------------------------------------------------
Test case output:
---------------- g++ 3.4.6 -----------------------
error! this == 0x80484b0, should be 0xafa60cdf
error! addr1 == 0x80484b0, should be 0xafa60cd8
--------------------------------------------------
---------------- g++ 4.0.4 -----------------------
error! this == 0x80484b0, should be 0xaf9eb45f
error! addr1 == 0x80484b0, should be 0xaf9eb458
--------------------------------------------------
---------------- g++ 4.1.2 -----------------------
error! this == 0x80484b0, should be 0xafbe265f
error! addr1 == 0x80484b0, should be 0xafbe2658
--------------------------------------------------
gcc versions tested: 3.4.6, 4.0.4, 4.1.2
>>>>> g++-3.4.6 -v <<<<<
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs
Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal
--prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls --without-included-gettext
--program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --with-tune=i686 i486-linux-gnu
Thread model: posix
gcc version 3.4.6 (Debian 3.4.6-4)
>>>>> g++-4.0.4 -v <<<<<
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.4 20060904 (prerelease) (Debian 4.0.3-7)
>>>>> g++-4.1.2 -v <<<<<
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
--
Summary: g++ calls to a regparm(3) pointer-to-member-function
pass wrong arguments
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: massimiliano dot ghilardi at gmail dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29911