[llvm-bugs] [Bug 50438] New: Warn when assigning to temporary
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 21 13:49:08 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50438
Bug ID: 50438
Summary: Warn when assigning to temporary
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: davidfromonline at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
I would like for there to be a warning that warns for the following code:
```
struct s {};
inline void f() {
s() = s();
}
```
I know that for a given type, I can prevent this from compiling if I give `s`
an lvalue-refererence-qualified assignment operator, but that requires writing
two assignment operators and two (sometimes three) constructors to get the
behavior I get today from not typing anything, and I have to apply it to every
type. It would be much nicer if I could just turn on a warning for this.
I don't know where this warning would belong in terms of `Wall` `Wextra` or
just `Weverything`. The only valid use case is if your assignment operator has
a side effect that you want.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210521/283686a3/attachment.html>
More information about the llvm-bugs
mailing list