Bug 33788 - [4.3 regression] GNAT bug box in expand_expr_addr_expr_1, at expr.c:6862
Summary: [4.3 regression] GNAT bug box in expand_expr_addr_expr_1, at expr.c:6862
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Eric Botcazou
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-10-15 20:40 UTC by Oliver Kellogg
Modified: 2008-01-12 22:44 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work: 4.2.3
Known to fail:
Last reconfirmed: 2008-01-12 00:24:02


Attachments
source files for reproducing the compiler bug (56.94 KB, application/x-gtar)
2007-10-15 20:41 UTC, Oliver Kellogg
Details
source code narrowed down to the bug trigger (603 bytes, application/x-gtar)
2007-12-14 04:26 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Kellogg 2007-10-15 20:40:26 UTC
Also tried this with the 20071005 snapshot, same result:

$ gcc -c -v -g mac6dw.adb 
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../SOURCES/gcc/configure --prefix=/opt/gcc4 --enable-debug --enable-languages=c,ada,c++
Thread model: posix
gcc version 4.3.0 20070929 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-v' '-g' '-mtune=generic'
 /opt/gcc4/libexec/gcc/i686-pc-linux-gnu/4.3.0/gnat1 -quiet -dumpbase mac6dw.adb -g -mtune=generic mac6dw.adb -o /tmp/cc3KSBQs.s
+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20070929 (experimental) (i686-pc-linux-gnu) GCC error:             |
| in expand_expr_addr_expr_1, at expr.c:6862                               |
| Error detected around mac6dw.adb:11                                      |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| 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.

mac6dw.adb
mac6dw.ads
mcc.ads
mcc-gui.ads
peer.ads
tcl.ads
cargv.ads
chelper.ads
tcl-ada.ads
mcc-gui-widget.ads
mcc-gui-container.ads
mcc-gui-widget-text_entry.ads
p_portable.ads
corba.ads
isf_dbase.ads
mdlp_messages.ads
p_spare.ads
basic_isf_types.ads
p_gedef.ads
l16_data_types.ads
l16_ada_types.ads
l16_data_2_types.ads
l16_if_types.ads

compilation abandoned
Comment 1 Oliver Kellogg 2007-10-15 20:41:59 UTC
Created attachment 14356 [details]
source files for reproducing the compiler bug
Comment 2 Oliver Kellogg 2007-10-21 15:44:21 UTC
Also happens with 4.3.0-20071021 r129524.
Does not happen with -O (optimize).
Comment 3 Oliver Kellogg 2007-12-11 09:36:52 UTC
Still happens with 20071211 r130768.
BTW the workaround is to introduce a temporary variable (LICG) as follows:

package body mac6dw is

  procedure Generate_Callforward is
      MADR : ISF_Dbase.Access_Mission_Assignment_Dbase_Rec_T
          := ISF_Dbase.Mission_Assignment_ISF (ISF_Dbase.Mission_Assignment);
      LICG : L16_Data_2_Types.Laser_Illuminator_Code_Group_T
                  := MADR.ISF.Laser_Illuminator_Code (0);
  begin
      Mcc.Gui.Widget.Text_Entry.Set_Text
        (Obj  => Laser_Illuminator_Code_0_te ,
         Text => L16_Data_2_Types.Laser_Illuminator_Code_Group_T'Image (LICG));

  end Generate_Callforward;

end mac6dw;
Comment 4 Oliver Kellogg 2007-12-14 04:26:56 UTC
Created attachment 14750 [details]
source code narrowed down to the bug trigger

Still happens with 20071213 r130895.
Comment 5 Samuel Tardieu 2007-12-14 10:44:20 UTC
Confirmed on SVN trunk. This is a new regression, the bug is not present in GCC 4.2.3 20071123.

===========================GNAT BUG DETECTED==============================+
| 4.3.0 20071213 (experimental) (i686-pc-linux-gnu) GCC error:             |
| in expand_expr_addr_expr_1, at expr.c:6861                               |
| Error detected around mac6dw.adb:7                                       |
Comment 6 Oliver Kellogg 2007-12-14 13:00:29 UTC
Backtrace using 20071213 r130895

(gdb) bt
#0  <__gnat_debug_raise_exception> (e=0x8b19390) at ../../../SOURCES/gcc/gcc/ada/s-except.adb:48
#1  0x080a5b9d in <__gnat_raise_nodefer_with_msg> (e=0x8b19390)
    at ../../../SOURCES/gcc/gcc/ada/a-except.adb:798
#2  0x080a64e4 in <__gnat_raise_exception> (e=0x8b19390, message=0x0)
    at ../../../SOURCES/gcc/gcc/ada/a-except.adb:833
#3  0x080cf819 in comperr.compiler_abort (code=-1, fallback_loc=0x90575b0)
    at ../../../SOURCES/gcc/gcc/ada/comperr.adb:398
#4  0x0806ae1e in internal_error_function (msgid=0x8a28f5f "in %s, at %s:%d["00"]", ap=0xbfffdf24)
    at ../../../SOURCES/gcc/gcc/ada/misc.c:427
#5  0x0833b5b0 in diagnostic_report_diagnostic (context=0x8fe8680, diagnostic=0xbfffdf00)
    at ../../../SOURCES/gcc/gcc/diagnostic.c:194
#6  0x0833b77a in internal_error (gmsgid=0x8a28f5f "in %s, at %s:%d["00"]")
    at ../../../SOURCES/gcc/gcc/diagnostic.c:606
#7  0x0833b7cf in fancy_abort (file=0x8a30bac "../../../SOURCES/gcc/gcc/expr.c["00"]", line=6861, 
    function=0x8a31382 "expand_expr_addr_expr_1["00"]")
    at ../../../SOURCES/gcc/gcc/diagnostic.c:660
#8  0x083a6d9e in expand_expr_addr_expr_1 (exp=<value optimized out>, target=0x401c9fe0, 
    tmode=SImode, modifier=EXPAND_NORMAL) at ../../../SOURCES/gcc/gcc/expr.c:6861
#9  0x08391db9 in expand_expr_real_1 (exp=0x401fb420, target=0x401c9fe0, tmode=SImode, 
    modifier=EXPAND_NORMAL, alt_rtl=0xbfffe18c) at ../../../SOURCES/gcc/gcc/expr.c:6891
#10 0x083a28ff in expand_expr_real (exp=0x401fb420, target=0x401c9fe0, tmode=SImode, 
    modifier=EXPAND_NORMAL, alt_rtl=0xbfffe18c) at ../../../SOURCES/gcc/gcc/expr.c:7087
#11 0x083a8d33 in store_expr (exp=0x401fb420, target=0x401c9fe0, call_param_p=0, 
    nontemporal=0 '["00"]') at ../../../SOURCES/gcc/gcc/expr.c:4571
#12 0x083ab877 in expand_assignment (to=0x401cd9a0, from=0x401fb420, nontemporal=0 '["00"]')
    at ../../../SOURCES/gcc/gcc/expr.c:4354
#13 0x0838f04b in expand_expr_real_1 (exp=0x401f9380, target=0x0, tmode=VOIDmode, 
    modifier=EXPAND_NORMAL, alt_rtl=0x0) at ../../../SOURCES/gcc/gcc/expr.c:9124
#14 0x083a2a67 in expand_expr_real (exp=0x401f9380, target=0x401c5200, tmode=VOIDmode, 
    modifier=EXPAND_NORMAL, alt_rtl=0x0) at ../../../SOURCES/gcc/gcc/expr.c:7081
#15 0x08506c6c in expand_expr_stmt (exp=0x401f9380) at ../../../SOURCES/gcc/gcc/expr.h:514
#16 0x088f14ef in expand_gimple_basic_block (bb=0x401bdfb4)
    at ../../../SOURCES/gcc/gcc/cfgexpand.c:1609
#17 0x088f25f6 in tree_expand_cfg () at ../../../SOURCES/gcc/gcc/cfgexpand.c:1918
#18 0x0849582a in execute_one_pass (pass=0x8b7f5a0) at ../../../SOURCES/gcc/gcc/passes.c:1118
#19 0x08495a1f in execute_pass_list (pass=0x8b7f5a0) at ../../../SOURCES/gcc/gcc/passes.c:1171
#20 0x0858095b in tree_rest_of_compilation (fndecl=0x401e7460)
    at ../../../SOURCES/gcc/gcc/tree-optimize.c:404
#21 0x08749da5 in cgraph_expand_function (node=0x401ca800)
    at ../../../SOURCES/gcc/gcc/cgraphunit.c:1151
#22 0x0874bf00 in cgraph_assemble_pending_functions ()
    at ../../../SOURCES/gcc/gcc/cgraphunit.c:522
#23 0x0874b71d in cgraph_finalize_function (decl=0x401e7460, nested=0 '["00"]')
    at ../../../SOURCES/gcc/gcc/cgraphunit.c:639
#24 0x0806e937 in end_subprog_body (body=0x401cebb8) at ../../../SOURCES/gcc/gcc/ada/utils.c:2136
#25 0x0809ae69 in gnat_to_gnu (gnat_node=1667) at ../../../SOURCES/gcc/gcc/ada/trans.c:1936
#26 0x080a2e16 in process_decls (gnat_decls=<value optimized out>, 
    gnat_decls2=<value optimized out>, gnat_end_list=0, pass1p=1 '["01"]', pass2p=1 '["01"]')
    at ../../../SOURCES/gcc/gcc/ada/trans.c:5737
#27 0x08094980 in gnat_to_gnu (gnat_node=1658) at ../../../SOURCES/gcc/gcc/ada/trans.c:4309
#28 0x080a3229 in Compilation_Unit_to_gnu (gnat_node=1651)
    at ../../../SOURCES/gcc/gcc/ada/trans.c:2976
#29 0x080a3919 in gigi (gnat_root=1651, max_gnat_node=4240, number_name=1641, 
    nodes_ptr=0x4031b008, next_node_ptr=0x404d3008, prev_node_ptr=0x40504008, 
    elists_ptr=0x9045d70, elmts_ptr=0x90463b8, strings_ptr=0x9071820, string_chars_ptr=0x906f108, 
    list_headers_ptr=0x90be238, number_file=5, file_info_ptr=0xbfffeb30, standard_integer=62, 
    standard_long_long_float=92, standard_exception_type=1225, gigi_operating_mode=0)
    at ../../../SOURCES/gcc/gcc/ada/trans.c:334
#30 0x082fceef in back_end.call_back_end (mode=generate_object)
    at ../../../SOURCES/gcc/gcc/ada/back_end.adb:100
#31 0x082fdda0 in gnat1drv () at ../../../SOURCES/gcc/gcc/ada/gnat1drv.adb:703
#32 0x0806ac85 in gnat_parse_file (set_yydebug=0) at ../../../SOURCES/gcc/gcc/ada/misc.c:240
#33 0x0851be2c in toplev_main (argc=2, argv=0xbfffef14) at ../../../SOURCES/gcc/gcc/toplev.c:1042
#34 0x082fe39f in main (argc=1836016485, argv=0x72726570) at ../../../SOURCES/gcc/gcc/main.c:35
Comment 7 Eric Botcazou 2008-01-12 00:24:02 UTC
Investigating.
Comment 8 Eric Botcazou 2008-01-12 22:40:34 UTC
Subject: Bug 33788

Author: ebotcazou
Date: Sat Jan 12 22:39:49 2008
New Revision: 131493

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131493
Log:
	PR ada/33788
	* fold-const.c (fold_unary) <VIEW_CONVERT_EXPR>: Fold an existing
	NOP_EXPR if it is between integral types with the same precision.


Added:
    trunk/gcc/testsuite/gnat.dg/bit_packed_array.adb
    trunk/gcc/testsuite/gnat.dg/bit_packed_array.ads
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/utils.c
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Eric Botcazou 2008-01-12 22:44:37 UTC
This should be OK now.