https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61597
Bug ID: 61597 Summary: Unexpected behavior at runtime Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: adrien.hamelin+gcc at gmail dot com When compiling the code visible at the link at the bottom, the compiler eat it fine and produce an executable, but it doesn't work. The problem is in the std::iota function present in the main. For the second parameter, "begin + size", the operator+ is effectively called and works as expected, but the result parameter given to the function is "begin" unmodified (checked with gdb in without optimizations). The code compiles and runs fine with Visual 13 and Clang 3.4.2. It also runs fine if i use a "std::vector" instead of my "Memory::Array", or if i use "std::next(begin, size)". I tried to remove all unnecessary code to show the bug. The option given to gcc are shown in the link, but it also doesn't work with no optimizations. I had the bug on Mingw64 with gcc4.9 on Windows 7 64, and also on the website. http://coliru.stacked-crooked.com/a/d6fde84b59d4526a