Hi, On my private port, I'm unable to debug an ICE on GCC4.7.3 (GNAT 7.1.2) during the internal test testsuite/gnat.dg/array18.adb.
Here is the test source code: ----------------- with Array18_Pkg; use Array18_Pkg; procedure Array18 is A : String (1 .. 1); begin A := F; end; ----------------- ----------------- package Array18_Pkg is function N return Positive; subtype S is String (1 .. N); function F return S; end Array18_Pkg; ----------------- The size of the String returned by 'F' can't be known at compile time. GNAT will compare the size of the returned string to the size of 'A' at runtime (to call last_chance_handler or not). The ICE is an assert inside force_constant_size of gimplify.c (at line 717) : --------------------------- static void force_constant_size (tree var) { /* The only attempt we make is by querying the maximum size of objects of the variable's type. */ HOST_WIDE_INT max_size; gcc_assert (TREE_CODE (var) == VAR_DECL); max_size = max_int_size_in_bytes (TREE_TYPE (var)); gcc_assert (max_size >= 0); <<<<<<<<<<<< max_size = -1 !! DECL_SIZE_UNIT (var) = build_int_cst (TREE_TYPE (DECL_SIZE_UNIT (var)), max_size); DECL_SIZE (var) = build_int_cst (TREE_TYPE (DECL_SIZE (var)), max_size * BITS_PER_UNIT); } --------------------------- The 'var' parameter contains : --------------------------- <var_decl 0x2aaaaabd9000 D.1430 type <array_type 0x2aaaaabb2f18 array18_pkg__s type <integer_type 0x2aaaaab02348 character sizes-gimplified public unsigned string-flag QI size <integer_cst 0x2aaaaaafe620 constant 8> unit size <integer_cst 0x2aaaaaafe640 constant 1> align 8 symtab 0 alias set -1 canonical type 0x2aaaaab02348 precision 8 min <integer_cst 0x2aaaaaafe660 0> max <integer_cst 0x2aaaaaafe5e0 255> context <translation_unit_decl 0x2aaaaab0b170 D.16> pointer_to_this <pointer_type 0x2aaaaab169d8 access_character>> sizes-gimplified visited nonaliased-component BLK size <mult_expr 0x2aaaaabd0210 type <integer_type 0x2aaaaab020a8 bitsizetype> readonly visited arg 0 <nop_expr 0x2aaaaabd1ed8 type <integer_type 0x2aaaaab020a8 bitsizetype> readonly visited arg 0 <var_decl 0x2aaaaaaff500 array18_pkg__R1s>> arg 1 <integer_cst 0x2aaaaaafe620 8>> unit size <nop_expr 0x2aaaaabd1fc8 type <integer_type 0x2aaaaab02000 sizetype> readonly visited arg 0 <var_decl 0x2aaaaaaff500 array18_pkg__R1s>> align 8 symtab 0 alias set 0 canonical type 0x2aaaaabb2f18 domain <integer_type 0x2aaaaabb2e70 type <integer_type 0x2aaaaab02000 sizetype> sizes-gimplified visited SI size <integer_cst 0x2aaaaaafe420 constant 32> unit size <integer_cst 0x2aaaaaafe440 constant 4> align 32 symtab 0 alias set -1 canonical type 0x2aaaaabb2e70 precision 32 min <integer_cst 0x2aaaaaafe640 1> max <nop_expr 0x2aaaaabd1dc0> index type <integer_type 0x2aaaaabb2bd0 array18_pkg__TsP1___XDL_1> chain <type_decl 0x2aaaaabd42e0 D.1403>> context <translation_unit_decl 0x2aaaaab0b170 D.16> chain <type_decl 0x2aaaaabd4398 array18_pkg__s>> used ignored BLK file /vues_statiques/FPGA/belbachir/prism/compiler/gcc_test/internal/../../gcc/gcc/testsuite/gnat.dg/array18.adb line 9 col 9 size <mult_expr 0x2aaaaabd0210> unit size <nop_expr 0x2aaaaabd1fc8> align 8> --------------------------- I used -fdump-tree-all option and run my cross compiler and the native x86_64 compiler (same GCC/GNAT version) to compare the dumps I don't have the same results event in the first dump : >> X86_64 array18.adb.003t.original : ------------------------------ Array18 () { typedef array18__TTaSP1___XDLU_1__1 array18__TTaSP1___XDLU_1__1; typedef <unnamed-signed:64> struct <unnamed-signed:64>; typedef character array18__TaS[1:1]; character a[1:1]; character R.0[1:(sizetype) (integer) array18_pkg__R1s]; typedef array18__TTaSP1___XDLU_1__1 array18__TTaSP1___XDLU_1__1; typedef <unnamed-signed:64> struct <unnamed-signed:64>; typedef character array18__TaS[1:1]; character a[1:1]; if (array18_pkg__R1s != 1) { .gnat_last_chance_handler ("array18.adb", 9); } else { } character R.0[1:(sizetype) (integer) array18_pkg__R1s]; R.0 = array18_pkg.f (); a = VIEW_CONVERT_EXPR<character[1:1]>(R.0); return; } _GLOBAL.SZ0.ada_array18 (integer p0, integer p1) { return p1 <= p0 ? (bitsizetype) ((((sizetype) p0 - (sizetype) p1) + 1) * 8) : 0; _GLOBAL.SZ1.ada_array18 (integer p0, integer p1) { return p1 <= p0 ? ((sizetype) p0 - (sizetype) p1) + 1 : 0; ------------------------------ >> MyPort array18.adb.003t.original : ------------------------------ Array18 () { typedef array18__TTaSP1___XDLU_1__1 array18__TTaSP1___XDLU_1__1; typedef <unnamed-signed:32> struct <unnamed-signed:32>; typedef character array18__TaS[1:1]; typedef struct array18__a___PAD array18__a___PAD; struct array18__a___PAD a; typedef array18__TTaSP1___XDLU_1__1 array18__TTaSP1___XDLU_1__1; typedef <unnamed-signed:32> struct <unnamed-signed:32>; typedef character array18__TaS[1:1]; typedef struct array18__a___PAD array18__a___PAD; struct array18__a___PAD a; if (array18_pkg__R1s != 1) { .gnat_last_chance_handler ("array18.adb", 9); } else { } a = {.F=VIEW_CONVERT_EXPR<character[1:1]>(array18_pkg.f ())}; return; } _GLOBAL.SZ0.ada_array18 (integer p0, integer p1) { return p1 <= p0 ? ((bitsizetype) ((sizetype) p0 - (sizetype) p1) + 1) * 8 : 0; _GLOBAL.SZ1.ada_array18 (integer p0, integer p1) { return p1 <= p0 ? ((sizetype) p0 - (sizetype) p1) + 1 : 0; ------------------------------ The next 004t.gimple dump is incomplete since the ICE is during gimplify pass. Using debugger I saw that the X86_64 port never goes inside force_constant_size (where is located the ICE on my port)... Can someone give me a hint to solve my problem ? I have no idea which part of my backend could be related to the GENERIC or GIMPLE generation and I'm very unfamiliar with this part of GCC. Regards, Selim Belbachir