public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luto at mit dot edu" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-58800-4@http.gcc.gnu.org/bugzilla/> (raw)

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 <algorithm>
#include <stdint.h>
//#include <iostream>

double to_double(uint64_t x)
{
        union {double d; uint64_t x;} u;
        u.x = x;
        return u.d;
}

int main()
{
        std::vector<double> 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;
}


             reply	other threads:[~2013-10-18 22:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 22:21 luto at mit dot edu [this message]
2013-10-18 22:22 ` [Bug libstdc++/58800] " luto at mit dot edu
2013-10-18 22:48 ` paolo.carlini at oracle dot com
2013-10-18 23:05 ` paolo.carlini at oracle dot com
2013-10-18 23:17 ` paolo.carlini at oracle dot com
2013-10-18 23:53 ` paolo.carlini at oracle dot com
2013-10-19  0:13 ` [Bug libstdc++/58800] [4.8.2/4.9 Regression] " luto at mit dot edu
2013-10-19  0:20 ` luto at mit dot edu
2013-10-19  0:22 ` paolo.carlini at oracle dot com
2013-10-19  0:35 ` luto at mit dot edu
2013-10-19  7:36 ` glisse at gcc dot gnu.org
2013-10-19  7:48 ` paolo.carlini at oracle dot com
2013-10-19  7:55 ` [Bug libstdc++/58800] [4.7.4/4.8.2/4.9 " chris at bubblescope dot net
2013-10-19  8:05 ` paolo.carlini at oracle dot com
2013-10-19  8:15 ` glisse at gcc dot gnu.org
2013-10-19  8:49 ` chris at bubblescope dot net
2013-10-19  8:54 ` chris at bubblescope dot net
2013-10-19 10:02 ` paolo.carlini at oracle dot com
2013-10-19 11:06 ` chris at bubblescope dot net
2013-10-19 12:11 ` chris at bubblescope dot net
2013-10-19 17:47 ` paolo.carlini at oracle dot com
2013-10-19 18:07 ` paolo.carlini at oracle dot com
2013-10-20  9:07 ` paolo at gcc dot gnu.org
2013-10-20  9:08 ` paolo at gcc dot gnu.org
2013-10-20  9:08 ` paolo at gcc dot gnu.org
2013-10-20  9:09 ` paolo.carlini at oracle dot com
2013-10-21  8:39 ` rguenth at gcc dot gnu.org
2013-11-13 15:59 ` [Bug libstdc++/58800] [4.7/4.8/4.9 " glisse at gcc dot gnu.org
2013-12-19 16:12 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58800-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).