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:
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
Fixed in 8.2.1-1.