The attached file uninitialized_field.adb demonstrates a case where a 
discriminant of a record isn't initialized. I compile and run it like this:

$ gnatmake uninitialized_field.adb
gcc -c uninitialized_field.adb
gnatbind -x uninitialized_field.ali
gnatlink uninitialized_field.ali
$ ./uninitialized_field
Initialized with Unified_Encoding_Record aggregate:
With predefined "=" - A1a and A2a: equal
Initialized with Character_Encoding aggregate:
With predefined "=" - A1b and A2b: not equal
With redefined "=" - B1c and B2c: equal
OS of A1a: LINUX
OS of A2a: LINUX
OS of A1b: OS2
OS of A2b:

raised CONSTRAINT_ERROR : uninitialized_field.adb:117 invalid data

Correct output would be:

Initialized with Unified_Encoding_Record aggregate:
With predefined "=" - A1a and A2a: equal
Initialized with Character_Encoding aggregate:
With predefined "=" - A1b and A2b: equal
With redefined "=" - B1c and B2c: equal
OS of A1a: LINUX
OS of A2a: LINUX
OS of A1b: LINUX
OS of A2b: LINUX

The other attached file, convert_to_pointer.ada, contains relevant parts 
of the code in uninitialized_field.adb, but here the declarations are in 
a package and are referenced from the main program. This causes a very 
strange error message:

$ gnatmake convert_to_pointer_package.ads
gcc -c convert_to_pointer_package.ads
$ LANG=en_US gnatmake convert_to_pointer_main.adb
gcc -c convert_to_pointer_main.adb
convert_to_pointer_package.ads: In function `Convert_To_Pointer_Main':
convert_to_pointer_package.ads:37: error: cannot convert to a pointer type
gnatmake: "convert_to_pointer_main.adb" compilation error

Both these test cases fail on all of the following compilers:

$ LANG=C gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1-20051112/configure
--prefix=/home/bjorn/ada/gcc-4.1-20051112-inst --enable-libada
--enable-languages=ada,c
Thread model: posix
gcc version 4.1.0 20051112 (experimental)

$ LANG=C gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)

$ gcc -v
Reading specs from
/home/bjorn/ada/gcc-3.4.0-inst/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: /home/bjorn/ada/gcc-3.4.0/configure
--prefix=/home/bjorn/ada/gcc-3.4.0-inst
Thread model: posix
gcc version 3.4.0

Note: I originally submitted these test cases to bug 17160, but that bug has
been fixed, and indeed that ICE no longer happens. These tests still fail
though, so I'm making a separate report for them.


-- 
           Summary: Discriminant is left uninitialized.
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: listor1 dot rombobeorn at comhem dot se
 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=25245

Reply via email to