I have a bit of a dilemma that I was hoping some of you may be able to shed some
light on. It is in relation to the program below (I know this isn't really the
place to discuss technical problems, but I'd appreciate any comment on this

The program below is a modified snippet of something I have to use. The problem
I have is that I have access to 4 compilers, namely Apex, Green Hills, GNAT and
ObjectAda that I have used to compile the code. All of them are quite happy to
compile the program, but I need to know whether I should be reporting this as a
bug to the supplier of the code, or the compiler vendors!

When I run the program, on both Green Hills and ObjectAda, with the pragma
Suppress commented out, a Constraint_Error is raised on the line:

    ZZZ_Control_Data := (Date => (Date, (Month => Control_Data.Month)));

If you look at the program you can see that Control_Data.Month has been assigned
a value of zero as a result of the unchecked conversion carried out on
Input_Data. A zero value is invalid for an object of type Month_Type which is
presumably the justification for ObjectAda and Green Hills raising a
Constraint_Error on that assignment.

On the other hand, both GNAT and Apex allow the program to run straight through,
printing out "Program Completed Successfully.", even with the -gnato option on
GNAT to enable additional overflow checks etc.

In all cases, inserting the pragma Suppress suppresses the Constraint_Error (I
know I shouldn't use All_Checks in the way I have, but it's only a test).

So, your comments, explanations and suggestions would be appreciated, as would
the result of running the program with compilers other than those listed.


with Ada.Text_Io;
with Ada.Unchecked_Conversion;

procedure Testy is

    -- pragma Supress (All_Checks);

    type Month_Type is (January,

    for Month_Type use (January    => 1,
                        February   => 2,
                        March      => 3,
                        April      => 4,
                        May        => 5,
                        June       => 6,
                        July       => 7,
                        August     => 8,
                        September  => 9,
                        October    => 10,
                        Novemember => 11,
                        December   => 12);

    for Month_Type'Size use 4;

    type ZZZ_Date_Type is
            Month : Month_Type;
        end record;

    type Natural_12_Bit_Type is range 0 .. (2 ** 12-1);
    for Natural_12_Bit_Type'Size use 12;

    type Natural_16_Bit_Type is range 0 .. (2 ** 16-1);
    for Natural_16_Bit_Type'Size use 16;

    type Request_Type is
            Spare : Natural_12_Bit_Type;
            Month : Month_Type;
        end record;
    for Request_Type use
            Spare at 0 range  0 .. 11;
            Month at 0 range 12 .. 15;
        end record;
    for Request_Type'Size use 16;

    type Data_Block_Type is array (1 .. 1) of Natural_16_Bit_Type;
    for Data_Block_Type'Size use 16;

    type ZZZ_Control_Fields is (Date);
    type ZZZ_Single_Value_Control_Type (Field : ZZZ_Control_Fields := Date) is
            case Field is
                when Date =>
                    Data : ZZZ_Date_Type := (Month => January);
            end case;

        end record;

    type ZZZ_Control_Data_Type is
        array (ZZZ_Control_Fields) of ZZZ_Single_Value_Control_Type;

    function To_Request_Block is new
        Ada.Unchecked_Conversion (Source => Data_Block_Type,
                                  Target => Request_Type);

    Control_Data : Request_Type;
    Input_Data   : Data_Block_Type := (others => 0);

    ZZZ_Control_Data : ZZZ_Control_Data_Type;


    Control_Data     := To_Request_Block (Input_Data);
    ZZZ_Control_Data := (Date => (Date, (Month => Control_Data.Month)));

    Ada.Text_Io.Put_Line ("Program Completed Successfully.");

    when Constraint_Error =>
        Ada.Text_Io.Put_Line  ("Constraint Error Raised.");

end Testy;

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender
immediately by telephoning +44(1252) 373232. You should not copy it
or use it for any purpose nor disclose or distribute its contents to
any other person.