Bug 1031495

Summary: gcc-c++ std::nth_element segfaults on valid input
Product: [Fedora] Fedora Reporter: Ben Webb <ben>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: jakub, laurent.rineau__fedora, law
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-15 23:52:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Ben Webb 2013-11-18 06:13:56 UTC
Description of problem:

A valid c++ program like this segfaults:

#include <algorithm>

int main() {
 double mm[] = {2, 2, 3, 2};
 size_t ms = sizeof(mm) / sizeof(double);
 std::nth_element(mm, mm+1, mm+ms);
}

because nth_element is broken

The bug has been reported and fixed upstream
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800

The same problem affects Fedora 20 and has been reported there as bug #1029217.

Comment 1 Laurent Rineau 2013-11-27 09:30:56 UTC
A lot of components of the Computational Geometry Algorithms Library (www.cgal.org) segfault because of that bug. The package CGAL-devel-4.2-1.fc19 is impacted.

Ubuntu has released a patched version:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1246802

I do not know about other Linux distributions, so far.

Comment 2 Laurent Rineau 2013-12-20 09:35:32 UTC
Seems fixed in libstdc++-devel-4.8.2-7.fc19