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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Szikra from comment #0)
> I thought (something like) this was fixed in bug 986
> 
> Code:
> struct TestRefInt {
>     TestRefInt(const int& a) : a_(a) {};
>     void DoSomething() {    cout << "int:" << a_ << endl;  }
> protected:
>     const int& a_;
> };

This is harder to diagnose than the 986 cases. There's nothing wrong with
binding the parameter 'a' to a temporary. And (in general) there's nothing
wrong with binding the reference member 'a_' to something that's already a
reference. The problem is indirect, and the two locations might not even be in
the same translation unit.

We still want a warning, but it's harder to do.


> struct TestRefIntDirect {
>     TestRefIntDirect(int a) : a_(a) {};
>     void DoSomething() {    cout << "int:" << a_ << endl;  }
> protected:
>     const int& a_;
> };

This is bug 44974.

> Possible duplicate of bug #44859 or bug #51270.

Looks more like bug 49974 to me.

*** This bug has been marked as a duplicate of bug 44974 ***

Reply via email to