Index: lib/Sema/SemaChecking.cpp =================================================================== --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -5724,7 +5724,7 @@ // If this is a reference variable, follow through to the expression that // it points to. if (V->hasLocalStorage() && - V->getType()->isReferenceType() && V->hasInit()) { + V->getType()->isLValueReferenceType() && V->hasInit()) { // Add the reference variable to the "trail". refVars.push_back(DR); return EvalAddr(V->getInit(), refVars, ParentDecl); Index: test/SemaCXX/rval-references.cpp =================================================================== --- test/SemaCXX/rval-references.cpp +++ test/SemaCXX/rval-references.cpp @@ -9,6 +9,15 @@ return 0; // expected-warning {{returning reference to local temporary}} } +namespace PR25356 { +int* foo(); + +int* bar() { + auto &&x = foo(); + return x; +} +} + struct not_int {}; int over(int&);