Bug 1600886

Summary: GCC/GNAT fails to optimize access to packed array
Product: [Fedora] Fedora Reporter: Maxim Reznik <reznikmm>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: aoliva, davejohansen, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-08-10 14:35:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer none

Description Maxim Reznik 2018-07-13 09:44:59 UTC
Created attachment 1458691 [details]
reproducer

Description of problem:

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

Version-Release number of selected component (if applicable):

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

How reproducible:
1. Install Ada compiler dnf --assumeyes install gcc-gnat
2. Compile and run attached code with optimization is on (-O1).
3. 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:

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

Additional info:

Comment 1 Maxim Reznik 2018-07-13 10:53:39 UTC
I've checked gcc 9 snapshot and bug is still there. I've filled upstream bug report

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

Comment 2 Marek Polacek 2018-08-10 14:35:02 UTC
Fixed in 8.2.1-1.