[Bug 1662495] Re: GCC 5 optimizer produces incorrect code

Egor Suvorov 1662495 at bugs.launchpad.net
Wed Feb 8 13:34:46 UTC 2017


Sidenote: we were unable to reproduce that bug on:
1. Ideone (they claim to use GCC 5.1, but do not specify which flavor it is).
2. tdm-gcc 5.1.0 on Windows.
3. gcc version 6.1.0 (Gentoo 6.1.0 p1.0)

And we were able to reproduce it on (in addition to what's mentioned in the report):
1. g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
2. gcc version 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1~14.04) 
3. gcc version 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~14.04)

That's why it's submitted to Ubuntu's bugtracker first.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-5 in Ubuntu.
https://bugs.launchpad.net/bugs/1662495

Title:
  GCC 5 optimizer produces incorrect code

Status in gcc-5 package in Ubuntu:
  Confirmed

Bug description:
  Inspired by the following blog post:
  http://codeforces.com/blog/entry/50291

  Attached file is a snippet of code which, when compiled with `g++
  a.cpp` produces an executable `a.out`, which runs correctly. But when
  compiled with `g++ a.cpp -O1` the resulting executable crashes in line
  10 (according to GDB). Looks like array out-of-bounds error happens
  despite corresponding check being present in the code.

  We was able to reproduce it on two independent installations of Ubuntu
  16.04, compiler version is `gcc version 5.4.0 20160609 (Ubuntu
  5.4.0-6ubuntu1~16.04.4)` (looks like it's the most recent package
  available as of February 7, 2017).

  Steps to reproduce:
  1. Download `a.cpp` attached.
  2. Run `g++ a.cpp -O1` and ensure that it finished without any errors.
  3. You can optionally run `g++ a.cpp -O1 -Wall -Wextra -Werror -pedantic` and ensure that this command finishes without any errors as well.
  4. Run `./a.out`.

  Expected behavior: program finishes correctly.

  Real behavior: program crashes with segmentation fault.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1662495/+subscriptions



More information about the foundations-bugs mailing list