public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100721] New: Warn when assigning to temporary
@ 2021-05-21 20:52 davidfromonline at gmail dot com
  2021-05-23 14:27 ` [Bug c++/100721] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: davidfromonline at gmail dot com @ 2021-05-21 20:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100721

            Bug ID: 100721
           Summary: Warn when assigning to temporary
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidfromonline at gmail dot com
  Target Milestone: ---

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.

The only valid use case is if your assignment operator has a side effect that
you want.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100721] Warn when assigning to temporary
  2021-05-21 20:52 [Bug c++/100721] New: Warn when assigning to temporary davidfromonline at gmail dot com
@ 2021-05-23 14:27 ` redi at gcc dot gnu.org
  2021-05-23 16:49 ` davidfromonline at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-23 14:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100721

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Blocks|                            |87403
           Keywords|                            |diagnostic


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100721] Warn when assigning to temporary
  2021-05-21 20:52 [Bug c++/100721] New: Warn when assigning to temporary davidfromonline at gmail dot com
  2021-05-23 14:27 ` [Bug c++/100721] " redi at gcc dot gnu.org
@ 2021-05-23 16:49 ` davidfromonline at gmail dot com
  2021-10-27  5:24 ` egallager at gcc dot gnu.org
  2021-10-27  5:25 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: davidfromonline at gmail dot com @ 2021-05-23 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100721

David Stone <davidfromonline at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davidfromonline at gmail dot com

--- Comment #1 from David Stone <davidfromonline at gmail dot com> ---
https://bugs.llvm.org/show_bug.cgi?id=50438 is the matching clang bug, so you
can coordinate on naming the flag.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100721] Warn when assigning to temporary
  2021-05-21 20:52 [Bug c++/100721] New: Warn when assigning to temporary davidfromonline at gmail dot com
  2021-05-23 14:27 ` [Bug c++/100721] " redi at gcc dot gnu.org
  2021-05-23 16:49 ` davidfromonline at gmail dot com
@ 2021-10-27  5:24 ` egallager at gcc dot gnu.org
  2021-10-27  5:25 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-10-27  5:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100721

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org
           See Also|                            |https://bugs.llvm.org/show_
                   |                            |bug.cgi?id=50438

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to David Stone from comment #1)
> https://bugs.llvm.org/show_bug.cgi?id=50438 is the matching clang bug, so
> you can coordinate on naming the flag.

Since it looks like it was confirmed there, I'll confirm it here, too.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100721] Warn when assigning to temporary
  2021-05-21 20:52 [Bug c++/100721] New: Warn when assigning to temporary davidfromonline at gmail dot com
                   ` (2 preceding siblings ...)
  2021-10-27  5:24 ` egallager at gcc dot gnu.org
@ 2021-10-27  5:25 ` egallager at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-10-27  5:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100721

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-10-27
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #2)
> (In reply to David Stone from comment #1)
> > https://bugs.llvm.org/show_bug.cgi?id=50438 is the matching clang bug, so
> > you can coordinate on naming the flag.
> 
> Since it looks like it was confirmed there, I'll confirm it here, too.

Oops, but for real this time

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-27  5:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 20:52 [Bug c++/100721] New: Warn when assigning to temporary davidfromonline at gmail dot com
2021-05-23 14:27 ` [Bug c++/100721] " redi at gcc dot gnu.org
2021-05-23 16:49 ` davidfromonline at gmail dot com
2021-10-27  5:24 ` egallager at gcc dot gnu.org
2021-10-27  5:25 ` egallager at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).