public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour
       [not found] <bug-986-4@http.gcc.gnu.org/bugzilla/>
@ 2011-08-04 13:03 ` redi at gcc dot gnu.org
  2011-11-13  5:54 ` jason at gcc dot gnu.org
  2011-11-15  5:48 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-04 13:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986

--- Comment #31 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-04 13:01:31 UTC ---
A similar case I've just added to a comment of PR 49974

struct Y {
    Y(int local) : ref(local) { }
    int& ref;
};

The reference is dangling as soon as the constructor exits, but in this case
it's bound to a block-scope function parameter with automatic storage duration,
not to a temporary.

I would imagine this could be caught in perform_member_init() by checking if
the member has reference type, then if the initializer has the same type but
DECL_FUNCTION_SCOPE_P is true warn about binding to a local.  But I haven't
tried to do that.


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

* [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour
       [not found] <bug-986-4@http.gcc.gnu.org/bugzilla/>
  2011-08-04 13:03 ` [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour redi at gcc dot gnu.org
@ 2011-11-13  5:54 ` jason at gcc dot gnu.org
  2011-11-15  5:48 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-13  5:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986

--- Comment #32 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-13 05:09:43 UTC ---
Author: jason
Date: Sun Nov 13 05:09:36 2011
New Revision: 181334

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181334
Log:
    PR c++/986
    * call.c (set_up_extended_ref_temp): Warn about references
    bound to non-static reference members.
    * init.c (perform_member_init): Pass in the member.

Added:
    trunk/gcc/testsuite/g++.dg/warn/ref-temp1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour
       [not found] <bug-986-4@http.gcc.gnu.org/bugzilla/>
  2011-08-04 13:03 ` [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour redi at gcc dot gnu.org
  2011-11-13  5:54 ` jason at gcc dot gnu.org
@ 2011-11-15  5:48 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-15  5:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=986

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #33 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-15 05:17:45 UTC ---
Added for 4.7.


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

end of thread, other threads:[~2011-11-15  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-986-4@http.gcc.gnu.org/bugzilla/>
2011-08-04 13:03 ` [Bug c++/986] g++ misses warning for reference on temporary that invokes undefined behaviour redi at gcc dot gnu.org
2011-11-13  5:54 ` jason at gcc dot gnu.org
2011-11-15  5:48 ` jason 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).