User account creation filtered due to spam.

Bug 10768

Summary: ICEs on compilation of ada support library for avr
Product: gcc Reporter: maierkom
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: berndtrog, denisc, eric.weddington, gcc-bugs, linux, marekm, rolf.ebert.gcc
Priority: P3 Keywords: ice-on-valid-code
Version: 3.4.0   
Target Milestone: 4.4.0   
Host: i686-pc-linux-gnu Target: avr
Build: Known to work:
Known to fail: Last reconfirmed: 2005-07-15 21:24:32
Attachments: file causing error
file causing error
file needed for compilation to create ICE
Bernd's patch that fixes the problem

Description maierkom 2003-05-13 12:06:00 UTC
I was trying to generate a minimum ada runtime library for the avr (e.g. at90s8535) by copying the required *.ads and *.adb files to <prefix>/lib/gcc-lib/avr/3.4/ada-include and compile them.

What I got was a number of ICEs of the form:
+===========================GNAT BUG DETECTED==============================+
| 3.4 20030509 (experimental) (avr-unknown-none) Gigi abort, Code=305      |
| No source file position information available                            |
| 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).                   |
+==========================================================================+

The files which generated errors were:
s-stalib.adb, s-parame.adb, i-c.adb, s-maccod.ads

I ran the compilation with 
avr-gcc -c -gnatg <filename>

flags -O and -mmcu=at90s8535 didn't make any difference

In file s-maccod.ads the reason for the ICE was the line:
pragma Import (Intrinsic, Asm);

In file i-c.ads the reason for the crash is the definition of type long:
type long  is range -(2 ** (System.Parameters.long_bits - 1))
     .. +(2 ** (System.Parameters.long_bits - 1)) - 1;

Release:
3.4 20030509

Environment:
host: linux-x86 (redhat 7.3)
Comment 1 Dara Hazeghi 2003-05-31 18:24:04 UTC
Hello,

your attachment to this bug report doesn't seem to have survived the bugzilla switchover. Can you 
please reattach the failing files? Thanks,

Dara
Comment 2 maierkom 2003-06-10 12:03:10 UTC
Created attachment 4193 [details]
file causing error

the line "pragma Import (Intrinsic, Asm);" causes an ICE;
this line is commented out in the attached file (line 119);

$ avr-gcc-3.4 -c -gnatg s-maccod.ads 
+===========================GNAT BUG DETECTED==============================+
| 3.4 20030509 (experimental) (avr-unknown-none) Gigi abort, Code=305	   |
| No source file position information available 			   |
| 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.


compilation abandoned
Comment 3 maierkom 2003-06-10 12:15:13 UTC
Created attachment 4194 [details]
file causing error

The attached file causes an error in lines 33,34 when compiling the body of
this package. commenting out the type definition in these lines and inserting
"type long is new Integer;" instead causes a warning but compiles without ICE.

I will attach the package body file in a new attachment as I don't know how to
get the form to accept multple file... BTW - can anybody tell me how to do
this???


$ avr-gcc-3.4 -c -gnatg i-c.adb
+===========================GNAT BUG DETECTED==============================+
| 3.4 20030509 (experimental) (avr-unknown-none) Gigi abort, Code=305	   |
| No source file position information available 			   |
| 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.


compilation abandoned
Comment 4 maierkom 2003-06-10 12:16:05 UTC
Created attachment 4195 [details]
file needed for compilation to create ICE
Comment 5 Andrew Pinski 2003-07-19 04:11:40 UTC
Changing to invalid to ...
Comment 6 Andrew Pinski 2003-07-19 04:12:03 UTC
change to unconfirmed.
Comment 7 Arnaud Charlet 2003-10-22 09:08:19 UTC
This is really specific to the avr port, so you would need to talk with the
avr maintainer on these issues.

Apparently basic things such as support for long is not properly
supported by the avr back end, and this is turn causes bug box in gnat.

Arno
Comment 8 berndtrog 2003-11-13 20:03:53 UTC
>This is really specific to the avr port, so you would need to talk with the
>avr maintainer on these issues.
>Apparently basic things such as support for long is not properly
>supported by the avr back end, and this is turn causes bug box in gnat.

Denis,
would you please take a look in the avr back end?
Maybe its easy to support 'long' properly..

Thanks,
Bernd
Comment 9 berndtrog 2004-10-06 17:03:52 UTC
Update:

gcc-head fails with
+===========================GNAT BUG DETECTED==============================+
| 4.0.0 20040917 (experimental) (avr-unknown-none) GCC error:              |
| in gnat_to_gnu, at ada/trans.c:2539                                      |
| No source file position information available                            |

compiling this:
--------- t.ads -------------
package T is
bug : Short_Integer;
end T;
--------- t.ads -------------
Comment 10 Eric Weddington 2005-02-11 19:38:47 UTC
Bernd, does this still fail on the most recent HEAD?

Eric
Comment 11 berndtrog 2005-02-14 20:02:45 UTC
>Bernd, does this still fail on the most recent HEAD?

Yes, it still fails:


+===========================GNAT BUG DETECTED==============================+
| 4.0.0 20050213 (experimental) (avr-unknown-none) GCC error:              |
| in gnat_to_gnu, at ada/trans.c:2536                                      |

compiling this:
--------- t.ads -------------
package T is
bug : Short_Integer;
end T;
--------- t.ads -------------
Comment 12 Rolf Ebert 2005-02-28 23:52:09 UTC
i-c.ad? use exceptions which are not supported on AVR anyhow.  The compiler 
issues a corresponding error message with gcc-3.4.3, no ICE.

s-maccod.ads compiles fine with gcc-3.4.3, no ICE.

The problem mentioned in comments 9 - 11 is not related to the original problem. 
 It deserves a separate entry in bugzilla.

I propose to close this entry here.
Comment 13 Andrew Pinski 2006-04-26 20:40:58 UTC
*** Bug 26849 has been marked as a duplicate of this bug. ***
Comment 14 Andrew Pinski 2006-04-26 20:42:20 UTC
(In reply to comment #12)
>  It deserves a separate entry in bugzilla.
> I propose to close this entry here.


I did the opposite and closed the other as a dup, since the orginal testcase still fails with ICEs.
Comment 15 Eric Weddington 2007-04-11 04:20:18 UTC
Bernd, Rolf,

Can you verify if this bug still exists? If so, I have in my notes that this patch will fix this bug:
<http://svn.sourceforge.net/viewvc/avr-ada/trunk/patches/gcc-4.1-integer-bug-workaround.patch?view=log>

If so, can you attach the patch to this bug report?

Thanks
Comment 16 Rolf Ebert 2007-04-30 09:57:48 UTC
(In reply to comment #15)
> Can you verify if this bug still exists? 

Yes, the problem is still present in 4.2

Bernd Trog developed a workaround available at
http://svn.sourceforge.net/viewvc/avr-ada/trunk/patches/gcc-4.1-integer-bug-workaround.patch?view=log
(sorry, I cannot attach it due to an internal error of bugzilla)

Also see the related discussion that started here
http://gcc.gnu.org/ml/gcc/2006-04/msg00512.html 

PR 30501 is a duplicate of this bug report and could be closed.


Comment 17 Arnaud Charlet 2007-04-30 09:59:44 UTC
*** Bug 30501 has been marked as a duplicate of this bug. ***
Comment 18 Rolf Ebert 2007-05-21 20:35:09 UTC
Created attachment 13597 [details]
Bernd's patch that fixes the problem

Bernd's patch as mentioned in comment #16
Comment 19 Arnaud Charlet 2007-05-22 09:51:14 UTC
Just to clarify: the patch posted is only a workaround/kludge, not a
real fix.

Arno
Comment 20 Eric Weddington 2007-05-22 14:24:09 UTC
Subject: RE:  ICEs on compilation of ada support library for
 avr

 

> -----Original Message-----
> From: charlet at gcc dot gnu dot org 
> [mailto:gcc-bugzilla@gcc.gnu.org] 
> Sent: Tuesday, May 22, 2007 2:51 AM
> To: eweddington@cso.atmel.com
> Subject: [Bug target/10768] ICEs on compilation of ada 
> support library for avr
> 
> 
> 
> ------- Comment #19 from charlet at gcc dot gnu dot org  
> 2007-05-22 09:51 -------
> Just to clarify: the patch posted is only a workaround/kludge, not a
> real fix.
> 
> Arno

Then what would be a real fix that could actually be approved and committed?

Eric Weddington

Comment 21 charlet@adacore.com 2007-05-22 14:26:27 UTC
Subject: Re:  ICEs on compilation of ada support library for avr

> Then what would be a real fix that could actually be approved and committed?

Fix support for long (or long long ?) in the avr back-end.

Arno
Comment 22 Peter Schildmann 2007-12-17 19:53:15 UTC
Hello,

when compiling the package

   package Integer_Test is
      type Int_Type is new Integer;
   end Integer_Test;

the ICE occures when the GNAT node that represents
the lower bound of the integer type is converted
to the corresponding INTERGER_CST node.

In the above case comp_type (gcc/ada/cuintp.c:87)
represents a signed integer type with 16 bit precision
which is to small for the computations performed later:

The call to build_cst_from_int (Base = 32768) at
line gcc/ada/cuintp.c:110

   gnu_base = build_cst_from_int (comp_type, Base);

returns an INTEGER_CST with the value -32768 which
causes an overflow (and later the ICE) in the call to

   fold_build2 (MULT_EXPR, comp_type,
			gnu_ret, gnu_base)

at line gcc/ada/cuintp.c:116.

See patch below.

Peter

-------------------------------------------

diff -Naur gcc-4.3-20071214.ORIG/gcc/ada/cuintp.c gcc-4.3-20071214/gcc/ada/cuintp.c
--- gcc-4.3-20071214.ORIG/gcc/ada/cuintp.c      2007-09-03 12:06:52.000000000 +0200
+++ gcc-4.3-20071214/gcc/ada/cuintp.c   2007-12-15 19:33:37.000000000 +0100
@@ -104,8 +104,8 @@
         convert the final result back to the incoming type later on.  */

       if (TREE_CODE (comp_type) != REAL_TYPE
-         && TYPE_PRECISION (comp_type) < TYPE_PRECISION (integer_type_node))
-       comp_type = integer_type_node;
+         && TYPE_PRECISION (comp_type) < TYPE_PRECISION (long_integer_type_node))
+       comp_type = long_integer_type_node;

       gnu_base = build_cst_from_int (comp_type, Base);

Comment 23 Arnaud Charlet 2008-04-08 06:46:48 UTC
Subject: Bug 10768

Author: charlet
Date: Tue Apr  8 06:46:04 2008
New Revision: 134013

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134013
Log:
2008-04-08  Tristan Gingold  <gingold@adacore.com>

PR ada/10768

	* cuintp.c: Fix 16 bits issue for AVR.
	On AVR, integer is 16 bits, so it can't be used to do math with
	Base (=32768).
	So use long_integer instead.


Modified:
    trunk/gcc/ada/cuintp.c

Comment 24 Arnaud Charlet 2008-04-08 07:25:26 UTC
Fixed on mainline.