I expect the following snippet to compile without errors (even a warning(s)
should be parametrized).

As stated in [class.temporary]/5, the temporaries can be bound to non-const
references too...

struct A {};

A fct() { return A(); }

int main(int, char**)
{
  const A& aConstRef = fct(); // compiles: temporary bound to const reference
  A& aRef = fct();            // error: temporary bound to non-const reference

  return 0;
}

I called g++ wo. parameters [sparc-sun-solaris2.8].

Ben


-- 
           Summary: temporary is not bound to non-const reference
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: istvan dot benedek dot ext at deutsche-boerse dot com


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

  • [Bug c++/26191] New... istvan dot benedek dot ext at deutsche-boerse dot com

Reply via email to