public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102223] New: no warning whel calling member function on dangling reference
@ 2021-09-06 20:32 federico.kircheis at gmail dot com
  2021-09-06 20:35 ` [Bug c++/102223] " federico.kircheis at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: federico.kircheis at gmail dot com @ 2021-09-06 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102223
           Summary: no warning whel calling member function on dangling
                    reference
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.kircheis at gmail dot com
  Target Milestone: ---

Consider this code-snippet

----
struct s{
    s() noexcept;
    ~s();
    int value() const noexcept;
};

s foo() noexcept;

int bar(){
  const auto& v = static_cast<s>(foo());
  int res = v.value();
  return res;
}
----

Normally life-extension would kick in, but because we added an unnecessary
static_cast, it does not kick in and v is a dangling reference.

GCC does not emit any warning

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

end of thread, other threads:[~2024-06-12 21:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 20:32 [Bug c++/102223] New: no warning whel calling member function on dangling reference federico.kircheis at gmail dot com
2021-09-06 20:35 ` [Bug c++/102223] " federico.kircheis at gmail dot com
2021-09-07  6:31 ` rguenth at gcc dot gnu.org
2021-09-07 21:32 ` [Bug c++/102223] no warning when " egallager at gcc dot gnu.org
2021-09-08 10:24 ` redi at gcc dot gnu.org
2021-09-08 10:28 ` redi at gcc dot gnu.org
2021-09-08 10:29 ` redi at gcc dot gnu.org
2021-09-08 19:31 ` federico.kircheis at gmail dot com
2021-09-08 21:12 ` redi at gcc dot gnu.org
2021-09-29  5:41 ` federico.kircheis at gmail dot com
2024-06-12 21:34 ` 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).