From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12083 invoked by alias); 24 Jun 2014 17:18:02 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12011 invoked by uid 48); 24 Jun 2014 17:17:57 -0000 From: "adrien.hamelin+gcc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61597] New: Unexpected behavior at runtime Date: Tue, 24 Jun 2014 17:18:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: adrien.hamelin+gcc at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg01889.txt.bz2 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