http://llvm.org/bugs/show_bug.cgi?id=7999
Summary: Warning about stack returns doesn't account for
reference type members
Product: clang
Version: unspecified
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
This shows up in Boost, here is the reduced test case:
template <typename T> struct S {
S(T& t) : value(t) {}
T& value;
};
struct X {};
X& f(S<X> s) { return s.value; }
void test(X& x) { (void)f(x); }
And the patch to fix:
--- a/trunk/tools/clang/lib/Sema/SemaChecking.cpp
+++ b/trunk/tools/clang/lib/Sema/SemaChecking.cpp
@@ -2028,10 +2028,15 @@ do {
MemberExpr *M = cast<MemberExpr>(E);
// Check for indirect access. We only want direct field accesses.
- if (!M->isArrow())
- return EvalVal(M->getBase());
- else
+ if (M->isArrow())
+ return NULL;
+
+ // Check whether the member type is itself a reference, in which case
we're
+ // not going to refer to the member, but to what the member refers to.
+ if (M->getMemberDecl()->getType()->isReferenceType())
return NULL;
+
+ return EvalVal(M->getBase());
}
// Everything else: we simply don't reason about them.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs