variable initialization with temporaries
Schilder
Frank.Schilder@Mathematik.Tu-Ilmenau.De
Wed Aug 30 13:09:00 GMT 2000
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
More information about the Gcc-bugs
mailing list