http://llvm.org/bugs/show_bug.cgi?id=8769
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: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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;
points.reserve(1);
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs