https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96783
Bug ID: 96783
Summary: [11 Regression] std::rotate miscompiled
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: rguenth at gcc dot gnu.org
Target Milestone: ---
This is miscompiled at -O3 since r11-1897 and dies with a segfault:
#include <vector>
#include <algorithm>
#include <iostream>
int main()
{
std::vector<std::vector<int>> c{{1,2}, {3,4}, {5,6}, {7,8}, {9,10}};
std::rotate(c.begin(), c.begin() + 3, c.end());
for (auto v : c)
{
for (auto i : v)
std::cout << i << ' ';
std::cout << '\n';
}
std::cout << '\n';
std::vector<std::vector<int>> c2{{7,8}, {9,10}, {1,2}, {3,4}, {5,6}};
if (c != c2)
throw 1;
}