https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91844
Bug ID: 91844 Summary: Implement CWG 2352, Similar types and reference binding Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- int *ptr; const int *const & f() { return ptr; } Here, a reference to a temporary is returned, because under the old wording, "int *" and "const int * const" are not reference-related, because they're not the same types. But this CWG changed the definition of "reference-related" to say “cv1 T1” is reference-related to “cv2 T2” if T1 is similar ([conv.qual]) to T2, or T1 is a base class of T2. http://eel.is/c++draft/dcl.init#def:reference-related So it seems we need to tweak reference_related_p, and then we will bind directly to ptr.