This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
variable initialization with temporaries
- To: gcc-bugs at gcc dot gnu dot org
- Subject: variable initialization with temporaries
- From: Schilder <Frank dot Schilder at Mathematik dot Tu-Ilmenau dot De>
- Date: Wed, 30 Aug 2000 22:14:26 +0200 (MET DST)
- Cc: fschild at gauss dot Mathematik dot TU-Ilmenau dot DE
Hi,
g++ has a problem with initializing variables with temporare values.
Unfortunately, this occours for automatically generated code, so there
is no work around. The code below worked with gcc 2.7.2.3 and
g++ egcs-2.91.66 and earlier.
It follows the minimum test program, the used version, the command line
and the command output. I used Solaris but I guess the problem is system
independend.
With kind regards,
Frank Schilder
### begin file bug.cpp
typedef unsigned int A;
class B
{
public:
B(A a, unsigned int b = 0) {}
};
class C
{
public:
C(const B & b1) {}
C(const B & b1, const B & b2) {}
};
int main()
{
// this works well:
C c1( B( A(1) ));
// this fails:
C c2( B( A(1) ), B( A(2) ) );
}
### end file bug.cpp
g++/gcc-version (g++/gcc -v):
Reading specs from /opt/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/specs
gcc version 2.95.2 19991024 (release)
command line:
g++ bug.cpp
command output:
bug.cpp: In function `int main()':
bug.cpp:22: redeclaration of `class B A'
bug.cpp:19: `class B A' previously declared here
bug.cpp:22: redeclaration of `class B A'
bug.cpp:22: `class B A' previously declared here