From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26535 invoked by alias); 18 Oct 2013 22:21:13 -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 26506 invoked by uid 48); 18 Oct 2013 22:21:10 -0000 From: "luto at mit dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/58800] New: [4.8 regression, I think] std::nth_element segfaults on valid input Date: Fri, 18 Oct 2013 22:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: luto at mit dot 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-10/txt/msg01315.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800 Bug ID: 58800 Summary: [4.8 regression, I think] std::nth_element segfaults on valid input Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: luto at mit dot edu This program segfaults on gcc 4.8.1 from Ubuntu 13.10. I'm building a copy of the 4.8 branch to see if I can reproduce it there. This is on x86_64. I used a gross hack to specify the input so I don't have to think about precision issues. The numbers are all well-behaved values near 0.9. I'll attach preprocessed source. The preprocessed source crashes even if built with gcc 4.7.something. #include #include //#include double to_double(uint64_t x) { union {double d; uint64_t x;} u; u.x = x; return u.d; } int main() { std::vector v = { to_double(4606672070890243784), to_double(4606672025854247510), to_double(4606671800674266141), to_double(4606671575494284772), to_double(4606672115926240057), to_double(4606672160962236330), to_double(4606672070890243784), }; // for (auto i : v) // std::cout << i << std::endl; std::nth_element(v.begin(), v.begin() + 3, v.end()); return 0; }