This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/49651] [C++0x] nested lambdas and -O3 produced incorrect integer variable increments
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Jul 2011 12:31:17 +0000
- Subject: [Bug tree-optimization/49651] [C++0x] nested lambdas and -O3 produced incorrect integer variable increments
- Auto-submitted: auto-generated
- References: <bug-49651-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49651
--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-13 12:31:13 UTC ---
Further reduced (-O2 vs. -O1):
#include <vector>
#include <algorithm>
extern "C" void abort (void);
typedef unsigned int u32;
using namespace std;
vector<u32> g;
void f(u32 b)
{
g.push_back(b);
for(int i=1; i<g.size() && ! g.empty(); ++i)
if ( g[i-1]+1 != g[i])
abort ();
}
int main(int argc, char *argv[])
{
u32 a = 0;
vector<int> vi;
vi.push_back(0);
vector<int> ve;
ve.push_back(5);
vector<int> v7;
auto run = [&](int& i) {
v7.push_back(i);
f(a++);
};
for_each(vi.begin(), vi.end(), [&](int& xi) {
f(a++);
for_each(ve.begin(), ve.end(), run);
f(a++);
for_each(ve.begin(), ve.end(), run);
});
}