class B
{
  public:
    B() {}
    explicit B(const B& ref) {}
};

void f(B obj) {}

int main()
{
  const B b;
  const B& r(b);
  f(b); // error: no matching function for call to 'B::B(const B&)'
        // error:   initializing argument 1 of 'void f(B)'
  f(r); // error: no matching function for call to 'B::B(const B&)'
        // error:   initializing argument 1 of 'void f(B)'
  return 0;
}

The problem is in casting from const B& to B, not in coustructor existence.


-- 
           Summary: missleading error message with explicit copy constructor
                    call
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: 4ertus2 at mail dot ru


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36183

Reply via email to