[LLVMbugs] [Bug 8769] New: wrong code with -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 10 02:56:48 PST 2010


           Summary: wrong code with -O2
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: marc.glisse at normalesup.org
                CC: llvmbugs at cs.uiuc.edu

When I compile the following code with clang++ -O1, it works fine. With clang++
-O2, it compiles fine but the resulting code crashes in the vector::push_back
(or in the placement new). I am using libstdc++-4.2 on debian-x64.

#include <vector>
#include <iterator>
#include <tr1/array>

typedef std::tr1::array<int,2> Point;

struct Generator_base {
    Point   d_item;
    double  d_range;
    Point const& operator*()  const { return d_item; }

template <class InputIterator,  class OutputIterator>
inline void copy_X( InputIterator first,
                       OutputIterator result)
    *result = *first;

int main() {
    std::vector<Point> points;
    Generator_base g;
    copy_X( g,  std::back_inserter(points));
    return 0;

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list