From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10546 invoked by alias); 8 Sep 2014 05:23:43 -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 10520 invoked by uid 48); 8 Sep 2014 05:23:37 -0000 From: "jzwinck at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63203] New: Self-initialization of reference not diagnosed if it occurs within a loop Date: Mon, 08 Sep 2014 05:23: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: normal X-Bugzilla-Who: jzwinck at gmail dot com 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: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-09/txt/msg01230.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D63203 Bug ID: 63203 Summary: Self-initialization of reference not diagnosed if it occurs within a loop Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jzwinck at gmail dot com The following is nonsensical yet compiles cleanly with "g++ -Wall -Wextra -Werror -Winit-self" (I tested GCC 4.7.2 and 4.9.0): #include #include int main() { for (int ii =3D 0; ii < 1; ++ii) { const std::string& str =3D str; // !! std::cout << str << std::endl; } } The line marked !! results in undefined behavior, yet is not diagnosed by G= CC. However, commenting out the for line makes GCC complain: error: =E2=80=98str=E2=80=99 is used uninitialized in this function [-W= error=3Duninitialized] If you change std::string to int and turn on optimization, GCC will diagnose the error even with the loop. Ref: http://stackoverflow.com/questions/25717740/why-is-gcc-tricked-into-allowin= g-undefined-behavior-simply-by-putting-it-in-a-lo >>From gcc-bugs-return-461397-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Sep 08 07:10:10 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 11378 invoked by alias); 8 Sep 2014 07:10:09 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 11348 invoked by uid 48); 8 Sep 2014 07:10:04 -0000 From: "ville.voutilainen at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63201] Full specialization of a member variable template of a class template does not work Date: Mon, 08 Sep 2014 07:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ville.voutilainen at gmail dot com X-Bugzilla-Status: NEW 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_status cf_reconfirmed_on everconfirmed Message-ID: In-Reply-To: References: 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: 2014-09/txt/msg01231.txt.bz2 Content-length: 414 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63201 Ville Voutilainen changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-09-08 Ever confirmed|0 |1