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

Matthias Klose doko at ubuntu.com
Sun Sep 17 09:30:13 UTC 2017


fixed in gcc-7

** Also affects: gcc-7 (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: gcc-7 (Ubuntu)
       Status: New => Fix Released

-- 
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
Status in gcc-7 package in Ubuntu:
  Fix Released

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