This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/21573] New: 'Valid attribute on enumeration types with holes


The program below is expected to print "SUCCESS" (because 0 is not a valid value
of type T).  However, at optimization level -O2 (on i686-pc-linux-gnu), it
prints "FAIL".

with Ada.Unchecked_Conversion;
with Ada.Text_IO; use Ada.Text_IO;

procedure Valid_Enumeration_Holes is

   type T is (A, B, C, D);
   for T'Size use 8;
   for T use (A => 2, B => 3, C => 5, D => 7);
   type N is mod 2**8;

   function Convert is new Ada.Unchecked_Conversion (N, T);

begin
   if Convert (N'Value ("0"))'Valid then
      Put_Line ("FAIL");
   else
      Put_Line ("SUCCESS");
   end if;
end Valid_Enumeration_Holes;

-- 
           Summary: 'Valid attribute on enumeration types with holes
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fw at deneb dot enyo dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21573


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]