https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86514

            Bug ID: 86514
           Summary: GCC/GNAT fails to optimize access to packed array
           Product: gcc
           Version: 8.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reznikmm at gmail dot com
  Target Milestone: ---

Created attachment 44390
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44390&action=edit
reproducer

Description of problem:

Ada compiler performs incorrect optimization of operations on a packed array of
Booleans.

Version-Release number of selected component:

Initially I found this on Fedora 28 and its gcc 8.1.1:

  gcc version 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC)
  RPM: gcc-gnat-8.1.1-1.fc28.x86_64

Then I checked gcc 9 snapshot 20180708 and it fails too. Configuration is:

  Target: x86_64-pc-linux-gnu
  Configured with: ../gcc-9-20180708/configure --enable-languages=c,c++,ada
--prefix=/work/reznik/gcc/install --enable-shared --enable-threads=posix
--disable-multilib
  Thread model: posix
  gcc version 9.0.0 20180708 (experimental) (GCC) 


How reproducible:
 * Compile and run attached code with optimization is on (-O1).
 * Without optimization (-O0) the example works well - without exception.

Actual results:

[max@4803f13cbde8 tmp]$ gnatmake -O1 ts_00021.adb 
gcc -c -O1 ts_00021.adb
gnatbind -x ts_00021.ali
gnatlink ts_00021.ali -O1
[max@4803f13cbde8 tmp]$ ./ts_00021 

raised PROGRAM_ERROR : ts_00021.adb:30 explicit raise

Expected results:
No exception should be raised.

Additional info:
Fedora bug report https://bugzilla.redhat.com/show_bug.cgi?id=1600886

Reply via email to