[PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 2 16:11:51 PDT 2018
Quuxplusone added a comment.
> The warning is fundamentally about dataflow, but this doesn't apply to unevaluated expressions. There are plenty of cases where a user might want to ask if assignment is well formed on noexcept using only one variable. For example:
>
> template <class T> void foo(T& value) noexcept(noexcept(value = value)) { /* perform an assignment somewhere */ }
My impression is that this case will not trigger the warning because the variable `value` is dependently typed.
I agree there should be a regression test for this exact case just to make sure of that.
@EricWF, is it important IYO that this warning not trigger in unevaluated contexts even for non-dependently-typed variables?
This is the case that seems to be coming up in practice in libc++ tests, but is hard to reason about because it's "only" deliberately contrived test code.
auto foo(std::exception& value)
noexcept(noexcept(value = value)) // ok to diagnose?
-> decltype(value = value) // ok to diagnose?
{
static_assert(noexcept(value = value)); // ok to diagnose?
}
Repository:
rC Clang
https://reviews.llvm.org/D44883
More information about the cfe-commits
mailing list