This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++-2.95.2 explicit constructor
- To: Mike Stump <mrs at windriver dot com>
- Subject: Re: g++-2.95.2 explicit constructor
- From: Ulf Larsson <ulf at sm dot luth dot se>
- Date: Wed, 26 Jan 2000 07:41:11 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <200001252016.MAA07135@kankakee.wrs.com>
Mike Stump wrote:
> > Date: Tue, 25 Jan 2000 11:22:43 +0100
> > From: Ulf Larsson <ulf@sm.luth.se>
> > To: gcc-bugs@gcc.gnu.org
>
> > struct A
> > {
> > explicit A(int);
> > };
>
> > struct B
> > {
> > B(A const &);
> > };
>
> > struct C
> > {
> > C(B const &);
> > };
>
> > void
> > f()
> > {
> > C c(B(A(1)));
> > }
>
> Are you missing B (A a) or A (A)? I'm wondering if this isn't a bug.
What makes me believe it is a bug is that g++-2.95.2 accept the code if
the explicit keyword is removed. And older version of the compiler such
as egcs-1.1.2 accept the code.
If g++-2.95.2 is correct then I find the error report a bit
confusing,"no matching function for call to `B::B (int)'". To me it
looks like g++ treat
C c(B(A(1)));
as
C c(B(1));
With explicit A::A(int) there is then no way to construct B from int.
The same problem appears if explicit A(int) is replaced by A(int,int)
and C c(B(A(1))) with C c(B(A(1,1)))
Ulf