🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1113

g++ 2.3.1 - wrong register argument passing

#1113
From: Bernd Anhaeupl
Date: Mon, 09 Nov 1992 19:19
41 lines
1548 bytes
gcc version: 2.3.1
HPUX-Version: 8.07
configure:   configure hp720-hpux --gas

gcc does not always save register arguments on the stack when calling other
functions with the address of one of these arguments as argument.

Example:
-----------------------------------------------------
#include <iostream.h>
inline conv(const char*c)
{
        cout << "conv arg:"<< *c << "\n";
        return *c;
}

class foo
{
  public:
        char rep;
        foo(char c);
};

inline foo::foo(char c)
:rep(conv(&c))					<--(1)
{
        rep=conv(&c);				<--(2)
        cout << "foo arg:" << c << "\n";
}

int main()
{
        char a='@';
        foo  b(a);
        return 0;
}
-------------------------------------------------------
The constructor foo::foo receives c in a register. It should initilize the
correspondig memory position before <--(1), since it must pass the memory location
of this variable to conv(...). Actually the initialization takes place just
before <--(2), which is too late.
Technical Details
Message-ID: <9211091719.AA19319@late.e-technik.uni-erlangen.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!late.e-technik.uni-erlangen.DE!anhaeupl

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!late.e-technik.uni-erlangen.DE!anhaeupl
From: anhaeupl@late.e-technik.uni-erlangen.DE (Bernd Anhaeupl)
Subject: g++ 2.3.1 - wrong register argument passing
Message-ID: <9211091719.AA19319@late.e-technik.uni-erlangen.de>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 9 Nov 1992 19:19:29 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 42