Bug 30501 - GNAT BUG BOX: 16-bit target & Standard.Integer
GNAT BUG BOX: 16-bit target & Standard.Integer
Status: RESOLVED DUPLICATE of bug 10768
Product: gcc
Classification: Unclassified
Component: ada
4.2.0
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-01-18 16:40 UTC by Peter Schildmann
Modified: 2007-04-30 09:59 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Schildmann 2007-01-18 16:40:20 UTC
psch@mozart:~/tmp/GNAT_Test$ m32c-elf-gcc -v -gnatv -gnatS -S --RTS=rts integer_test.ads
Using built-in specs.
Target: m32c-elf
Configured with: ../gcc-4.2-20070110/configure --target=m32c-elf --prefix=/home/psch/tmp/GNAT_Test/localinst --enable-languages=c,ada --disable-nls --disable-multilib --disable-libada --disable-libssp --program-prefix=m32c-elf-
Thread model: single
gcc version 4.2.0 20070110 (prerelease)
 /home/psch/tmp/GNAT_Test/localinst/libexec/gcc/m32c-elf/4.2.0/gnat1 -quiet -dumpbase integer_test.ads -fRTS=rts -gnatv -gnatS integer_test.ads -o integer_test.s

GNAT 4.2.0 20070110 (prerelease)
Copyright 1992-2006, Free Software Foundation, Inc.
--  Representation of package Standard

--  This is not accurate Ada, since new base types cannot be
--  created, but the listing shows the target dependent
--  characteristics of the Standard types for this compiler

package Standard is
pragma Pure(Standard);

   type Boolean is (False, True);
   for Boolean'Size use 1;
   for Boolean use (False => 0, True => 1);

   type Integer is range -(2 **15) .. +(2 **15 - 1);
   for Integer'Size use 16;

   subtype Natural  is Integer range 0 .. Integer'Last;
   subtype Positive is Integer range 1 .. Integer'Last;

   type Short_Short_Integer is range -(2 **7) .. +(2 **7 - 1);
   for Short_Short_Integer'Size use 8;

   type Short_Integer is range -(2 **15) .. +(2 **15 - 1);
   for Short_Integer'Size use 16;

   type Long_Integer is range -(2 **31) .. +(2 **31 - 1);
   for Long_Integer'Size use 32;

   type Long_Long_Integer is range -(2 **63) .. +(2 **63 - 1);
   for Long_Long_Integer'Size use 64;

   type Short_Float is digits 6
     range -16#0.FFFF_FF#E+32 .. 16#0.FFFF_FF#E+32;
   for Short_Float'Size use 32;

   type Float is digits 6
     range -16#0.FFFF_FF#E+32 .. 16#0.FFFF_FF#E+32;
   for Float'Size use 32;

   type Long_Float is digits 15
     range -16#0.FFFF_FFFF_FFFF_F8#E+256 .. 16#0.FFFF_FFFF_FFFF_F8#E+256;
   for Long_Float'Size use 64;

   type Long_Long_Float is digits 15
     range -16#0.FFFF_FFFF_FFFF_F8#E+256 .. 16#0.FFFF_FFFF_FFFF_F8#E+256;
   for Long_Long_Float'Size use 64;

   type Character is (...)
   for Character'Size use 8;
   --  See RM A.1(35) for details of this type

   type Wide_Character is (...)
   for Wide_Character'Size use 16;
   --  See RM A.1(36) for details of this type

   type Wide_Wide_Character is (...)
   for Wide_Character'Size use 32;
   --  See RM A.1(36) for details of this type
   type String is array (Positive range <>) of Character;
   pragma Pack (String);

   type Wide_String is array (Positive range <>) of Wide_Character;
   pragma Pack (Wide_String);

   type Wide_Wide_String is array (Positive range <>)  of Wide_Wide_Character;
   pragma Pack (Wide_Wide_String);

   type Duration is delta 0.000000001
     range -((2 ** 63 - 1) * 0.000000001) ..
           +((2 ** 63 - 1) * 0.000000001);
   for Duration'Small use 0.000000001;

   Constraint_Error : exception;
   Program_Error    : exception;
   Storage_Error    : exception;
   Tasking_Error    : exception;
   Numeric_Error    : exception renames Constraint_Error;

end Standard;

Compiling: integer_test.ads (source file time stamp: 2007-01-18 16:23:40)
+===========================GNAT BUG DETECTED==============================+
| 4.2.0 20070110 (prerelease) (m32c-unknown-elf) GCC error:                |
| in gnat_to_gnu, at ada/trans.c:2675                                      |
| No source file position information available                            |
| 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.

integer_test.ads

 14 lines: No errors
compilation abandoned

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

The bug also occures with avr-elf.

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

integer_test.ads:

package Integer_Test is

   -- type Int_Type is new Short_Short_Integer;  -- OK
   -- type Int_Type is new Short_Integer;        -- GNAT BUG BOX
   type Int_Type is new Integer;              -- GNAT BUG BOX (M32C: same as Short_Integer)
   -- type Int_Type is new Long_Integer;         -- OK
   -- type Int_Type is new Long_Long_Integer;    -- OK

   -- type Int_Type is range -(2 **15) .. +(2 **15 - 1);   -- OK (M32C: same as Integer)
   -- for Int_Type'Size use 16;

   Var : Int_Type;

end Integer_Test;

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

The "RTS" consist of the single file "rts/adainclude/system.ads":

------------------------------------------------------------------------------
--                                                                          --
--                        GNAT RUN-TIME COMPONENTS                          --
--                                                                          --
--                               S Y S T E M                                --
--                                                                          --
--                                 S p e c                                  --
--                            (Compiler Version)                            --
--                                                                          --
--          Copyright (C) 1992-2005 Free Software Foundation, Inc.          --
--                                                                          --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the  contents of the part following the private keyword. --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

package System is
   pragma Pure;
   --  Note that we take advantage of the implementation permission to make
   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
   --  2005, this is Pure in any case (AI-362).

   type Name is (SYSTEM_NAME_M32C);
   System_Name : constant Name := SYSTEM_NAME_M32C;

   --  System-Dependent Named Numbers

   Min_Int               : constant := Long_Long_Integer'First;
   Max_Int               : constant := Long_Long_Integer'Last;

   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
   Max_Nonbinary_Modulus : constant := Integer'Last;

   Max_Base_Digits       : constant := Long_Long_Float'Digits;
   Max_Digits            : constant := Long_Long_Float'Digits;

   Max_Mantissa          : constant := 63;
   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);

   Tick                  : constant := 0.01;

   --  Storage-related Declarations

   type Address is private;
   Null_Address : constant Address;

   Storage_Unit : constant := Standard'Storage_Unit;
   Word_Size    : constant := Standard'Word_Size;
   Memory_Size  : constant := 2 ** Standard'Address_Size;

   --  Address comparison

   function "<"  (Left, Right : Address) return Boolean;
   function "<=" (Left, Right : Address) return Boolean;
   function ">"  (Left, Right : Address) return Boolean;
   function ">=" (Left, Right : Address) return Boolean;
   function "="  (Left, Right : Address) return Boolean;

   pragma Import (Intrinsic, "<");
   pragma Import (Intrinsic, "<=");
   pragma Import (Intrinsic, ">");
   pragma Import (Intrinsic, ">=");
   pragma Import (Intrinsic, "=");

   --  Other System-Dependent Declarations

   type Bit_Order is (High_Order_First, Low_Order_First);
   Default_Bit_Order : constant Bit_Order :=
                         Bit_Order'Val (Standard'Default_Bit_Order);

   --  Priority-related Declarations (RM D.1)

   Max_Priority           : constant Positive := 30;
   Max_Interrupt_Priority : constant Positive := 31;

   subtype Any_Priority       is Integer      range  0 .. 31;
   subtype Priority           is Any_Priority range  0 .. 30;
   subtype Interrupt_Priority is Any_Priority range 31 .. 31;

   Default_Priority : constant Priority := 15;

private

   type Address is mod Memory_Size;
   Null_Address : constant Address := 0;

   -----------------------------------------------------------------
   -- System Implementation Parameters (see gcc/ada/targparm.ads) --
   -----------------------------------------------------------------

   -------------------
   -- Run Time Name --
   -------------------

   Run_Time_Name : constant String := "M32C";

   -----------------------
   -- Target Parameters --
   -----------------------

   Compiler_System_Version   : constant Boolean := False;

   ----------------------------
   -- Special Target Control --
   ----------------------------

   AAMP                      : constant Boolean := False;
   OpenVMS                   : constant Boolean := False;

   -------------------------------
   -- Backend Arithmetic Checks --
   -------------------------------

   Backend_Divide_Checks     : constant Boolean := False;
   Backend_Overflow_Checks   : constant Boolean := False;

   -----------------------------------
   -- Control of Exception Handling --
   -----------------------------------

   ZCX_By_Default            : constant Boolean := True;
   GCC_ZCX_Support           : constant Boolean := True;

   ------------------------------------
   -- Run-Time Library Configuration --
   ------------------------------------

   Configurable_Run_Time     : constant Boolean := True;
   Suppress_Standard_Library : constant Boolean := True;
   Preallocated_Stacks       : constant Boolean := True;

   ---------------------
   -- Duration Format --
   ---------------------

   Duration_32_Bits          : constant Boolean := False;

   ------------------------------------
   -- Back-End Code Generation Flags --
   ------------------------------------

   Support_64_Bit_Divides    : constant Boolean := True;
   Support_Aggregates        : constant Boolean := True;
   Support_Composite_Assign  : constant Boolean := True;
   Support_Composite_Compare : constant Boolean := True;
   Support_Long_Shifts       : constant Boolean := True;

   -------------------------------
   -- Control of Stack Checking --
   -------------------------------

   Stack_Check_Default       : constant Boolean := False;
   Stack_Check_Probes        : constant Boolean := False;

   ----------------------------
   -- Command Line Arguments --
   ----------------------------

   Command_Line_Args         : constant Boolean := False;
   Exit_Status_Supported     : constant Boolean := False;

   -----------------------
   -- Main Program Name --
   -----------------------

   Use_Ada_Main_Program_Name : constant Boolean := False;

   ----------------------------------------------
   -- Boolean-Valued Floating-Point Attributes --
   ----------------------------------------------

   Denorm                    : constant Boolean := True;
   Machine_Overflows         : constant Boolean := False;
   Machine_Rounds            : constant Boolean := False;
   Signed_Zeros              : constant Boolean := True;

   -------------------------------------------
   -- Boolean-Valued Fixed-Point Attributes --
   -------------------------------------------

   Fractional_Fixed_Ops      : constant Boolean := False;

   --------------------------------------------------------------
   -- Handling of Unconstrained Values Returned from Functions --
   --------------------------------------------------------------
   --  Depressed Stack Pointer

   Functions_Return_By_DSP   : constant Boolean := False;

   -----------------
   -- Data Layout --
   -----------------

   Frontend_Layout           : constant Boolean := False;

end System;
Comment 1 Rolf Ebert 2007-03-08 15:15:00 UTC
This is probably the same problem as mentioned in PR-10768 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10768).  See comments #9 - #11.

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

Also see the discussion that started here http://gcc.gnu.org/ml/gcc/2006-04/msg00512.html
Comment 2 Arnaud Charlet 2007-04-30 09:59:44 UTC
Closing, since duplicate of 10768

*** This bug has been marked as a duplicate of 10768 ***