https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86303

            Bug ID: 86303
           Summary: Constructor is not used for type conversion
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The code is as follow:

struct auto_ptr {
 struct auto_ptr_ref { };

 auto_ptr(auto_ptr&);
 auto_ptr(auto_ptr_ref);

 operator auto_ptr_ref();
};

auto_ptr foo();

struct X {
 X(auto_ptr);
};

struct Y {
 Y(X);
};

Y f(foo());

clang++ accepts the code, but g++ rejects it:

error: cannot bind non-const lvalue reference of type 'auto_ptr&' to an rvalue
of type 'auto_ptr'
 Y f(foo());
     ~~~^~

The code comes from a clang report: https://bugs.llvm.org/show_bug.cgi?id=7055

Eli Friedman constructed the code, and identified that  clang and comeau accept
it while g++ rejects it.

Reply via email to