I'm trying to build ncurses with an Ada-enabled compiler and get this: << much stuff not included >> gcc -c -I./ -O3 -gnatpn -I. -I. -I- ./terminal_interface-curses-aux.adb gcc -c -I./ -O3 -gnatpn -I. -I. -I- ./terminal_interface-curses.adb +===========================GNAT BUG DETECTED==============================+ | 3.3.3 (sparcv9-sun-solaris2) in expand_expr, at expr.c:7512 | | Error detected at ./terminal_interface-curses.adb:1987:34 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Include the entire contents of this bug box in the report. | | Include the exact gcc or gnatmake command that you entered. | | Also include sources listed below in gnatchop format | | concatenated together with no headers between files. | +==========================================================================+ Please include these source files with error report ./terminal_interface-curses.adb ./terminal_interface-curses.ads ./terminal_interface.ads ./terminal_interface-curses-aux.ads compilation abandoned gnatmake: "./terminal_interface-curses.adb" compilation error make[2]: *** [terminal_interface-curses-aux.o] Error 4 make[2]: Leaving directory `/root/build/ncurses-5.4/Ada95/src' make[2]: Entering directory `/root/build/ncurses-5.4/Ada95/samples' cp ./explain.txt explain.msg gnatmake -a -A. -A../src -A./../src tour -cargs -O3 -gnatpn -I. -largs - L../../lib -L../lib -lform -lmenu -lpanel -lncurses -R /root/build/ncurses- 5.4/lib:/usr/local/lib -lAdaCurses gcc -c -I. -I../src -I./../src -O3 -gnatpn -I. tour.adb gcc -c -I./ -I. -I../src -I./../src -O3 -gnatpn -I. -I- - gnatpg /usr/local/lib/gcc-lib/sparcv9-sun-solaris2/3.3.3/adainclude/s- stalib.adb gcc -c -I. -I../src -I./../src -O3 -gnatpn -I. sample.adb terminal_interface-curses-menus.ads:141:33: size for "Menu_Option_Set" too small, minimum allowed is 64 terminal_interface-curses-menus.ads:164:33: size for "Item_Option_Set" too small, minimum allowed is 64 gnatmake: "sample.adb" compilation error make[2]: *** [tour] Error 4 make[2]: Leaving directory `/root/build/ncurses-5.4/Ada95/samples' make[1]: *** [all] Error 2 make[1]: Leaving directory `/root/build/ncurses-5.4/Ada95' make: *** [all] Error 2 [root@lurch ncurses-5.4]# gcc -v Reading specs from /usr/local/lib/gcc-lib/sparcv9-sun-solaris2/3.3.3/specs Configured with: ../configure --enable-languages=all --disable-nls --with- ld=/usr/ccs/bin/ld --with-as=/usr/ccs/bin/as sparcv9-sun-solaris2 Thread model: posix gcc version 3.3.3 The configure line for ncurses was simply ./configure --enable-shared; make I'll include the gnatchop files in different posts to this ticket.
Created attachment 6100 [details] 1/4
Created attachment 6101 [details] 2/4
Created attachment 6102 [details] 3/4
Created attachment 6103 [details] 4/4
Can you try a snapshot of 3.4.0 as the Ada front-end in 3.3.x is known not to be the best Ada compiler?
Compiles at -O0 but blows up at -O1 and above on x86-linux HEAD for me. $ gcc -c -O1 terminal_interface-curses.adb +===========================GNAT BUG DETECTED==============================+ | 3.5.0 20040417 (experimental) (i686-pc-linux-gnu) GCC error: | | in expand_expr_real, at expr.c:7137 | | Error detected at terminal_interface-curses.adb:1989:34 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Include the entire contents of this bug box in the report. | | Include the exact gcc or gnatmake command that you entered. | | Also include sources listed below in gnatchop format | | (concatenated together with no headers between files). | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. terminal_interface-curses.adb terminal_interface-curses.ads terminal_interface.ads terminal_interface-curses-aux.ads compilation abandoned
Ok, then confirming: /* In this case, BITPOS must start at a byte boundary and TARGET, if specified, must be a MEM. */ if (GET_CODE (op0) != MEM || (target != 0 && GET_CODE (target) != MEM) || bitpos % BITS_PER_UNIT != 0) abort (); So this looks like an Ada front-end bug.
Ah, that did indeed fix that particular problem. I knocked out the -O3 and it compiled that one fine. (Still having issues with other parts, though, but they don't seem gcc-related.) It seems to be an issue with the -O level.
*** Bug 14998 has been marked as a duplicate of this bug. ***
Here is a reduced test cases that ICE even at -O0. But the problem is that the user code is incorrect, it assumes that Interfaces.C.Unsigned_Long is 64 bits, however it is 32 bits. In the aux package C_Chtype should be declared as: type C_Chtype is mod 2**64; Then everything should work (it compiles, I cannot test fully). On the GCC side, if the code does the assignement in two steps, I get a warning not a blow up: X : constant C_Chtype := 0; Y : Character_Attribute_Set; Z : Attributed_Character; begin Z := Chtype_To_AttrChar (X); Y := Z.Attr; $ gcc -c -O1 pq.adb pq.adb:70:04: warning: types for unchecked conversion have different sizes So on the front-end side, a warning should be generated and may be a way not to ICE in back-end could be found. Generated code will be meaningless anyway. Laurent $ gcc -c -O0 pq.adb +===========================GNAT BUG DETECTED==============================+ | 3.5.0 20040417 (experimental) (i686-pc-linux-gnu) GCC error: | | in expand_expr_real, at expr.c:7137 | | Error detected at pq.adb:78:29 | -- with Interfaces.C; use Interfaces.C; with Ada.Unchecked_Conversion; procedure PQ is subtype C_ULong is Interfaces.C.unsigned_long; type C_Chtype is new C_ULong; type Character_Attribute_Set is record Stand_Out : Boolean; Under_Line : Boolean; Reverse_Video : Boolean; Blink : Boolean; Dim_Character : Boolean; Bold_Character : Boolean; Alternate_Character_Set : Boolean; Invisible_Character : Boolean; Protected_Character : Boolean; Horizontal : Boolean; Left : Boolean; Low : Boolean; Right : Boolean; Top : Boolean; Vertical : Boolean; end record; pragma Pack (Character_Attribute_Set); pragma Convention (C, Character_Attribute_Set); for Character_Attribute_Set use record Stand_Out at 0 range 47 .. 47; Under_Line at 0 range 46 .. 46; Reverse_Video at 0 range 45 .. 45; Blink at 0 range 44 .. 44; Dim_Character at 0 range 43 .. 43; Bold_Character at 0 range 42 .. 42; Alternate_Character_Set at 0 range 41 .. 41; Invisible_Character at 0 range 40 .. 40; Protected_Character at 0 range 39 .. 39; Horizontal at 0 range 38 .. 38; Left at 0 range 37 .. 37; Low at 0 range 36 .. 36; Right at 0 range 35 .. 35; Top at 0 range 34 .. 34; Vertical at 0 range 33 .. 33; end record; for Character_Attribute_Set'Size use 48; type Color_Pair is range 0 .. 255; for Color_Pair'Size use 8; type Attributed_Character is record Attr : Character_Attribute_Set; Color : Color_Pair; Ch : Character; end record; pragma Convention (C, Attributed_Character); -- This is the counterpart for the chtype in C. for Attributed_Character use record Ch at 0 range 56 .. 63; Color at 0 range 48 .. 55; Attr at 0 range 0 .. 47; end record; for Attributed_Character'Size use 64; function Chtype_To_AttrChar is new Ada.Unchecked_Conversion (Source => C_Chtype, Target => Attributed_Character); X : constant C_Chtype := 0; Y : Character_Attribute_Set; begin Y := Chtype_To_AttrChar (X).Attr; end PQ;
On the mainline I get a different ICE: +===========================GNAT BUG DETECTED==============================+ | 4.0.0 20041121 (experimental) (powerpc-apple-darwin7.6.0) GCC error: | | RTL flag check: MEM_VOLATILE_P used with unexpected rtx code | | 'const_int' in extract_fixed_bit_field, at expmed.c:1687 | | Error detected at pq.adb:79:5 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Include the entire contents of this bug box in the report. | | Include the exact gcc or gnatmake command that you entered. | | Also include sources listed below in gnatchop format | | (concatenated together with no headers between files). | +============================================================== ============+
Here is a further simplification of the test case: procedure PQ is subtype C_ULong is Interfaces.C.unsigned_long; type C_Chtype is new C_ULong; type Character_Attribute_Set is array (0 .. 47) of Boolean; pragma Pack (Character_Attribute_Set); type Attributed_Character is record Attr : Character_Attribute_Set; Color : Character; Ch : Character; end record; pragma Convention (C, Attributed_Character); -- This is the counterpart for the chtype in C. for Attributed_Character use record Attr at 0 range 0 .. 47; Color at 0 range 48 .. 55; Ch at 0 range 56 .. 63; end record; for Attributed_Character'Size use 64; function Chtype_To_AttrChar is new Ada.Unchecked_Conversion (C_Chtype, Attributed_Character); X : constant C_Chtype := 0; Y : Character_Attribute_Set; begin Y := Chtype_To_AttrChar (X).Attr; end PQ; The expected output of the compilation is: gcc -c pq.adb pq.adb:27:04: warning: types for unchecked conversion have different sizes I assume the incorrect code in the ncurses Ada binding has been fixed in the mean time. Anyway, GNAT should not ICE here. Arno
Looking into it for AdaCore.
Recategorizing.
Subject: Bug 14997 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2005-09-06 19:47:09 Modified files: gcc : ChangeLog expr.c Log message: PR middle-end/14997 * expr.c (expand_expr_real) <normal_inner_ref>: Force op0 to mem when we would be extracting outside its bit span (bitpos+bitsize larger than its mode), possible with some VIEW_CONVERT_EXPRs from Ada unchecked conversions. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9904&r2=2.9905 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.814&r2=1.815
See http://gcc.gnu.org/ml/gcc-patches/2005-09/msg00324.html