Comment 3 for bug 1246802

Revision history for this message
In , Andy Lutomirski (luto-mit) wrote :

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;
}