From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10873 invoked by alias); 4 Jun 2013 18:07:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10832 invoked by uid 48); 4 Jun 2013 18:06:55 -0000 From: "jewillco at osl dot iu.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57528] New: Missed warning for putting reference to temporary in class member Date: Tue, 04 Jun 2013 18:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jewillco at osl dot iu.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg00188.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57528 Bug ID: 57528 Summary: Missed warning for putting reference to temporary in class member Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jewillco at osl dot iu.edu It would be nice to have a warning on code such as: struct b { const int& r; b(int r): r(r) {} }; that is almost certainly unintended since it always binds a reference to a temporary in a case where the reference outlives the temporary. "g++ (GCC) 4.9.0 20130519 (experimental)" does not warn on this code with -Wall -Wextra, whether with -O2 or without. Uses of the struct b (including with a literal number as constructor argument) do not produce warnings either.