Bug 26306 - [4.0 regression] ICE on volatile array with non-constant bounds
Summary: [4.0 regression] ICE on volatile array with non-constant bounds
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.2
Assignee: Eric Botcazou
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-15 16:39 UTC by ben midgley
Modified: 2006-11-16 21:34 UTC (History)
2 users (show)

See Also:
Host: *-*-*
Target: *-*-*
Build: *-*-*
Known to work:
Known to fail:
Last reconfirmed: 2006-11-05 13:03:17


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ben midgley 2006-02-15 16:39:32 UTC
I have included the configure, and build command below. 

This seems really easy to reproduce, 
create and array of integer values (I am unsure if integer is significant)  
the upper bound of which is determined by a function call
declare the array as volatile

+===========================GNAT BUG DETECTED==============================+
| 4.0.2 (i686-pc-cygwin) in tree_low_cst, at tree.c:3850                   |
| Error detected at mfd_transmitter.2.ada:540:9                            |
| 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).                   |
+==========================================================================+ 

This error can be avoided by using a fixed size array or removing the volatile from the array. 


gcc -c -g -fstack-check -gnata -gnato -gnatE -gnatf -I- -gnatA -x ada project_top.adb

$ gcc -v
Using built-in specs.
Target: i686-pc-cygwin
Configured with: ../gcc-4.0.2/configure --enable-languages=ada --disable-win32-registry
Thread model: single
gcc version 4.0.2
Comment 1 Arnaud Charlet 2006-02-15 16:52:30 UTC
Could you please send full sources to reproduce this problem ? thanks.

Arno
Comment 2 ben midgley 2006-02-15 17:56:53 UTC
(In reply to comment #1)
> Could you please send full sources to reproduce this problem ? thanks.
> Arno

Arno, what follows is a simple bit of code which causes the assertion failure described in tree.c, In constructing this it became apparent that the bug report should read use of volatile array, within a record, with bounds determined at run time. I hope this clarifies the issue. 

---scratch.ada--------

	with system; 
	with Interfaces.c;
	
procedure scratch is 

	-- to get a value for the upper bound of the array 
    type my_Integer is range -2147483648 .. 2147483647;

    for my_Integer'Size use 32;
    
	function GetArrayUpperBound return my_integer is 
	begin
	return 2;
	end GetArrayUpperBound;	

	some_value : my_integer := GetArrayUpperBound;

    type Gp_Element_Type is
    record
        Element : Interfaces.C.Unsigned;
    end record;
	
	
	type some_type is
       array
          (1 .. some_value )
          of
          Gp_Element_Type;
          
        type Aligned_Some_Type is
            record
                Value : aliased some_type;
            end record;          

    for Aligned_Some_Type'Alignment use 8;          
    
	an_aligned_type : aligned_Some_Type;   
	my_address : system.address; 
          
	-- remember volatile too 
	              
    pragma Volatile (an_aligned_type);


	begin
        
		my_address := an_aligned_type.value( 1 )'address; 
	
	
	end scratch;      
	
	


Comment 3 Arnaud Charlet 2006-02-15 18:05:34 UTC
Thanks, reopening.

Confirmed on trunk with simple command:

$ gcc -c scratch.adb
+===========================GNAT BUG DETECTED==============================+
| 4.2.0 20060210 (experimental) (i686-pc-linux-gnu) GCC error:             |
| in tree_low_cst, at tree.c:4420                                          |
| Error detected at scratch.adb:50:13                                      |
[...]
Comment 4 jeff 2006-10-20 16:56:19 UTC
I just did a fresh Gcc build today this no longer appears to be a problem
URL: svn://gcc.gnu.org/svn/gcc/trunk
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 117904
Node Kind: directory
Schedule: normal
Last Changed Author: fxcoudert
Last Changed Rev: 117904
Last Changed Date: 2006-10-20 07:52:56 -0400 (Fri, 20 Oct 2006)
Properties Last Updated: 2006-10-20 09:33:34 -0400 (Fri, 20 Oct 2006)


[jcreem@timone mat_test]$ gcc -c scratch.adb
[jcreem@timone mat_test]$

 gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --disable-checking --enable-languages=c,fortran,ada --prefix=/home/jcreem/local
Thread model: posix
gcc version 4.2.0 20061020 (experimental)

Comment 5 Arnaud Charlet 2006-11-01 19:39:18 UTC
You built GCC with --disable-checking, which is not a good idea (in particular
with GCC >= 4.1, at a minimum you should use --enable-checking=release).

this bug is still present in trunk:

<<
gcc -c scratch.adb 
+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20061101 (experimental) (i686-pc-linux-gnu) GCC error:             |
| in force_constant_size, at gimplify.c:708                                |
| Error detected around scratch.adb:47                                     |
>>
Comment 6 Eric Botcazou 2006-11-01 20:02:52 UTC
> this bug is still present in trunk:

Right.  It may already be fixed in our internal tree though.
Comment 7 Eric Botcazou 2006-11-05 13:02:40 UTC
"included in the description" is not a target.
Comment 8 Eric Botcazou 2006-11-05 13:03:17 UTC
Testing fix.
Comment 9 patchapp@dberlin.org 2006-11-05 20:40:23 UTC
Subject: Bug number PR middle-end/26306

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00251.html
Comment 10 Eric Botcazou 2006-11-16 21:25:28 UTC
Subject: Bug 26306

Author: ebotcazou
Date: Thu Nov 16 21:25:16 2006
New Revision: 118900

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118900
Log:
	PR middle-end/26306
	* gimplify.c (gimplify_expr): Only force a load for references to
	non-BLKmode volatile values.
	* doc/implement-c.texi (Qualifiers implementation): Document the
	interpretation of what a volatile access is.
	* doc/extend.texi (C++ Extensions): Rework same documentation.


Added:
    trunk/gcc/testsuite/gnat.dg/volatile_aggregate.adb
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/extend.texi
    trunk/gcc/doc/implement-c.texi
    trunk/gcc/gimplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 11 Eric Botcazou 2006-11-16 21:27:46 UTC
Subject: Bug 26306

Author: ebotcazou
Date: Thu Nov 16 21:27:32 2006
New Revision: 118901

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118901
Log:
	PR middle-end/26306
	* gimplify.c (gimplify_expr): Only force a load for references to
	non-BLKmode volatile values.
	* doc/implement-c.texi (Qualifiers implementation): Document the
	interpretation of what a volatile access is.
	* doc/extend.texi (C++ Extensions): Rework same documentation.


Added:
    branches/gcc-4_2-branch/gcc/testsuite/gnat.dg/volatile_aggregate.adb
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/doc/extend.texi
    branches/gcc-4_2-branch/gcc/doc/implement-c.texi
    branches/gcc-4_2-branch/gcc/gimplify.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 12 Eric Botcazou 2006-11-16 21:30:37 UTC
Subject: Bug 26306

Author: ebotcazou
Date: Thu Nov 16 21:30:22 2006
New Revision: 118902

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118902
Log:
	PR middle-end/26306
	* gimplify.c (gimplify_expr): Only force a load for references to
	non-BLKmode volatile values.
	* doc/implement-c.texi (Qualifiers implementation): Document the
	interpretation of what a volatile access is.
	* doc/extend.texi (C++ Extensions): Rework same documentation.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/doc/extend.texi
    branches/gcc-4_1-branch/gcc/doc/implement-c.texi
    branches/gcc-4_1-branch/gcc/gimplify.c

Comment 13 Eric Botcazou 2006-11-16 21:34:23 UTC
Fixed in 4.1.2 and later.