public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11326] New: C++ IA64 ABI: 3.1.4: sometimes pointer to temporary return value is implicit first parameter preceding “this”
@ 2003-06-26 10:59 Vyatcheslav dot Sysoltsev at intel dot com
  2003-06-26 12:11 ` [Bug c++/11326] " schwab at suse dot de
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Vyatcheslav dot Sysoltsev at intel dot com @ 2003-06-26 10:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3275 bytes --]

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11326

           Summary: C++ IA64 ABI: 3.1.4: sometimes pointer to temporary
                    return value is implicit first parameter preceding
                    “this”
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Vyatcheslav dot Sysoltsev at intel dot com
                CC: gcc-bugs at gcc dot gnu dot org

According to C++ Itanium ABI (http://www.codesourcery.com/cxx-
abi/abi.html#calls) clause 3.1.4 if the return value type has a non-trivial 
copy constructor or destructor the caller allocates space for a temporary, and 
passes a pointer to the temporary as an implicit first parameter preceding both 
the “this” parameter and user parameters. The callee then constructs the return 
value into this temporary.
	I tried gcc 3.2 on United Linux 1.0 and found that this rule is 
violated, “this” pointer is always r32 and the value returned in different ways 
but never the way described in this part of ABI.
	Here is a test case that demonstrates the problem:
test.cc:
#include <stdio.h>
#include <stdlib.h>

struct ConstructedObject {
    ConstructedObject() {};
    ~ConstructedObject() {};
    ConstructedObject(const ConstructedObject &from) {};
};

struct FrameworkObject {
    ConstructedObject action();
};

ConstructedObject FrameworkObject::action() {
    void *r32, *r33;

    asm("mov %0 = r32\nmov %1 = r33" : "=r"(r32), "=r"(r33) : );
    printf("In FrameworkObject, this = %lx, r32 = %lx, r33 = %lx\n", this, r32, 
r33);
    if (this != r33) {
        printf ("Test failed\n");
        exit(-1);
    }
};

int main()
{
    FrameworkObject slawa;
    slawa.action();
    return 0;
}

command line: g++ -g -O0 test.cc && a.out
Output:
In FrameworkObject, this = 60000fffffffb270, r32 = 60000fffffffb270, r33 = 
6000000000000de0
Test failed

Test fails because according to ABI r32 is a placeholder for returned object, 
r33 is “this” pointer.
Because gcc violates C++ Itanium ABI such way, binaries built by gcc can be 
incompatible with binaries built by other compiler. To avoid such a situation 
C++ ABI standard was created. All compilers must honor it, gcc must in greater 
degree as the most popular one, that's why I set P1 priority.

The bug is reproducible both with gcc 3.2 and gcc 3.4.
/usr/bin/g++ -v
Reading specs from /usr/lib/gcc-lib/ia64-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-
prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --
libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --
with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --
enable-shared --enable-__cxa_atexit ia64-suse-linux
Thread model: posix
gcc version 3.2

/mnt/scratch/compiler/gcc-3.4-IA64/usr/local/bin/g++ -v
Reading specs from /mnt/scratch/compiler/gcc-3.4-IA64/usr/local/bin/../lib/gcc-
lib/ia64-unknown-linux-gnu/3.4/specs
Configured with: ./configure
Thread model: posix
gcc version 3.4 20030603 (experimental)


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2004-02-18 14:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-26 10:59 [Bug c++/11326] New: C++ IA64 ABI: 3.1.4: sometimes pointer to temporary return value is implicit first parameter preceding “this” Vyatcheslav dot Sysoltsev at intel dot com
2003-06-26 12:11 ` [Bug c++/11326] " schwab at suse dot de
2003-08-07  3:34 ` [Bug c++/11326] [ABI] " pinskia at physics dot uc dot edu
2003-08-11 16:19 ` pinskia at gcc dot gnu dot org
2003-08-11 17:58 ` schwab at suse dot de
2003-08-24 16:35 ` pinskia at gcc dot gnu dot org
2003-10-21 16:24 ` nathan at gcc dot gnu dot org
2004-01-15 22:15 ` [Bug c++/11326] C++ IA64 ABI: 3.1.4: sometimes pointer to temporary return value is implicit first parameter preceding "this" steven at gcc dot gnu dot org
2004-02-12 18:19 ` giovannibajo at libero dot it
2004-02-12 18:28 ` giovannibajo at libero dot it
2004-02-16  5:52 ` mmitchel at gcc dot gnu dot org
2004-02-17 18:33 ` cvs-commit at gcc dot gnu dot org
2004-02-18  0:09 ` cvs-commit at gcc dot gnu dot org
2004-02-18  0:11 ` mmitchel at gcc dot gnu dot org
2004-02-18 10:33 ` schwab at suse dot de
2004-02-18 14:21 ` cvs-commit at gcc dot gnu dot org
2004-02-18 14:22 ` cvs-commit at gcc dot gnu dot org
2004-02-18 14:48 ` schwab at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).