From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14758 invoked by alias); 23 Jan 2008 18:15:08 -0000 Received: (qmail 14750 invoked by uid 22791); 23 Jan 2008 18:15:07 -0000 X-Spam-Check-By: sourceware.org Received: from mailgw1a.lmco.com (HELO mailgw1a.lmco.com) (192.31.106.7) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 23 Jan 2008 18:14:39 +0000 Received: from emss07g01.ems.lmco.com (relay5.ems.lmco.com [166.29.2.16])by mailgw1a.lmco.com (LM-6) with ESMTP id m0NIDY6c003186for ; Wed, 23 Jan 2008 11:13:34 -0700 (MST) Received: from CONVERSION2-DAEMON.lmco.com by lmco.com (PMDF V6.3-x14 #31428) id <0JV400B0100EW9@lmco.com> for gcc-help@gcc.gnu.org; Wed, 23 Jan 2008 11:14:38 -0700 (MST) Received: from EMSS01I00.us.lmco.com ([137.249.139.145]) by lmco.com (PMDF V6.3-x14 #31428) with ESMTP id <0JV4008H2009Y1@lmco.com> for gcc-help@gcc.gnu.org; Wed, 23 Jan 2008 11:14:33 -0700 (MST) Received: from EMSS01M14.us.lmco.com ([137.249.139.149]) by EMSS01I00.us.lmco.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 23 Jan 2008 10:14:33 -0800 Date: Thu, 24 Jan 2008 13:15:00 -0000 From: "Wealand, Barry" Subject: PowerPC implicit pass-by-reference for structs? To: gcc-help@gcc.gnu.org Message-id: <8F507E88CEE37244AF6947A3E0E479DF160C055A@emss01m14.us.lmco.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-class: urn:content-classes:message Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00226.txt.bz2 Hello - I'm experimenting with powerpc-eabi-g++ for both v3.4.4 and v4.1.1 of GCC. In the past, we've also used mips-elf-g++ for a similar set of experiments. We define "trivial structs" to introduce new types, and then use operator overloading to re-define some of the behaviors associated with these new types. For example, we might have: struct new_int { int value; }; I observe that if I pass these new types by value into functions, the compiler treats them as implicit pass-by-reference: instead of a new_int value being passed in, an address is passed in. So, for example: static new_int saved; void store(new_int a) { saved = a; } If I compile this with powerpc-eabi-g++, code is produced that uses r3 (the first argument register) as an address rather than a value. If I compile the same code using mips-elf-g++, the code produced treats the first argument register as a value, not an address. Is there some combination of command-line switches, perhaps, (or any other methodology) that would let the PowerPC compiler produce pass-by-value code? Thanks! Barry Wealand barry.wealand@lmco.com