This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g++-2.95.2 explicit constructor


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]