public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/25245] New: Discriminant is left uninitialized.
@ 2005-12-03 17:52 listor1 dot rombobeorn at comhem dot se
2005-12-03 17:54 ` [Bug ada/25245] " listor1 dot rombobeorn at comhem dot se
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: listor1 dot rombobeorn at comhem dot se @ 2005-12-03 17:52 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
@ 2005-12-03 17:54 ` listor1 dot rombobeorn at comhem dot se
2005-12-03 17:55 ` listor1 dot rombobeorn at comhem dot se
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: listor1 dot rombobeorn at comhem dot se @ 2005-12-03 17:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from listor1 dot rombobeorn at comhem dot se 2005-12-03 17:54 -------
Created an attachment (id=10397)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10397&action=view)
demonstrates uninitialized discriminant
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
2005-12-03 17:54 ` [Bug ada/25245] " listor1 dot rombobeorn at comhem dot se
@ 2005-12-03 17:55 ` listor1 dot rombobeorn at comhem dot se
2005-12-04 21:11 ` laurent at guerby dot net
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: listor1 dot rombobeorn at comhem dot se @ 2005-12-03 17:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from listor1 dot rombobeorn at comhem dot se 2005-12-03 17:55 -------
Created an attachment (id=10398)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10398&action=view)
demonstrates strange error message
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
2005-12-03 17:54 ` [Bug ada/25245] " listor1 dot rombobeorn at comhem dot se
2005-12-03 17:55 ` listor1 dot rombobeorn at comhem dot se
@ 2005-12-04 21:11 ` laurent at guerby dot net
2005-12-05 19:54 ` laurent at guerby dot net
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: laurent at guerby dot net @ 2005-12-04 21:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from laurent at guerby dot net 2005-12-04 21:11 -------
The problem is that you are using "Unbounded_String" in your record, and this
brings in lots of dope information for Finalization purposes. You can see it
with:
gcc -c -gnatR3 uninitialized_field.adb
...
for Unified_Encoding_Record'Object_Size use 384;
for Unified_Encoding_Record'Value_Size use (if (#1 != 1) then (if (#2 == 2)
then 384 else 208 end) else 200 end) ;
for Unified_Encoding_Record'Alignment use 4;
for Unified_Encoding_Record use record
_Controller at 4 range 0 .. 159;
Known at 0 range 0 .. 7;
Os at 1 range 0 .. 7;
Which at 24 range 0 .. 7;
Name at 24 range 0 .. 191;
Number at 24 range 0 .. 15;
end record;
...
If you replace Unbounded_String with Character (or any other non controlled
like a subtype String5 is string (1..5)) your program does work without problem
(4.2.0 20051202).
I assume you used 'address and stuff in your test case but not in your original
program. Could you provide a test case without 'address that has a suspicious
behaviour (even if not all the times)?
Laurent
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
` (2 preceding siblings ...)
2005-12-04 21:11 ` laurent at guerby dot net
@ 2005-12-05 19:54 ` laurent at guerby dot net
2005-12-06 22:21 ` listor1 dot rombobeorn at comhem dot se
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: laurent at guerby dot net @ 2005-12-05 19:54 UTC (permalink / raw)
To: gcc-bugs
--
laurent at guerby dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
` (3 preceding siblings ...)
2005-12-05 19:54 ` laurent at guerby dot net
@ 2005-12-06 22:21 ` listor1 dot rombobeorn at comhem dot se
2005-12-09 19:51 ` laurent at guerby dot net
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: listor1 dot rombobeorn at comhem dot se @ 2005-12-06 22:21 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]
------- Comment #4 from listor1 dot rombobeorn at comhem dot se 2005-12-06 22:21 -------
Subject: Re: Discriminant is left uninitialized.
laurent at guerby dot net wrote:
> The problem is that you are using "Unbounded_String" in your record, and
> this brings in lots of dope information for Finalization purposes.
Your comment puzzles me. Do you really mean that the unbounded string is what
causes the problem? Yes, I understand that it's involved in triggering the
bug, but do you mean I should expect problems when using a controlled type
inside a record type?
> I assume you used 'address and stuff in your test case but not in your
> original program.
Yes. That was only to make the test case reproducible.
> Could you provide a test case without 'address that has a
> suspicious behaviour (even if not all the times)?
I'm attaching uninitialized_field_2.adb, which is the same program but without
the address clauses. Here's what I get when I run it:
$ gnatmake uninitialized_field_2.adb
gcc -c uninitialized_field_2.adb
gnatbind -x uninitialized_field_2.ali
gnatlink uninitialized_field_2.ali
$ ./uninitialized_field_2
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:
raised CONSTRAINT_ERROR : uninitialized_field_2.adb:92 invalid data
Björn Persson
------- Comment #5 from listor1 dot rombobeorn at comhem dot se 2005-12-06 22:21 -------
Created an attachment (id=10429)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10429&action=view)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
` (4 preceding siblings ...)
2005-12-06 22:21 ` listor1 dot rombobeorn at comhem dot se
@ 2005-12-09 19:51 ` laurent at guerby dot net
2005-12-09 22:35 ` listor1 dot rombobeorn at comhem dot se
2005-12-10 13:26 ` laurent at guerby dot net
7 siblings, 0 replies; 9+ messages in thread
From: laurent at guerby dot net @ 2005-12-09 19:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from laurent at guerby dot net 2005-12-09 19:51 -------
I see the same thing as you on trunk x86-linux with gcc version 4.2.0 20051202
(experimental).
I agree the "not equal" part is a bug:
With predefined "=" - A1b and A2b: not equal
should print "equal".
But the constraint_error for "OS of A1b" looks correct, and if commented the
one on "OS of A2b", it is a language mandated discriminant check failing. But
may be I'm missing something, could you explain why you think an exception
shouldn't be raised?
Today Ada front-end commits may have fixed the bug, I'm retesting.
--
laurent at guerby dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-12-09 19:51:33
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
` (5 preceding siblings ...)
2005-12-09 19:51 ` laurent at guerby dot net
@ 2005-12-09 22:35 ` listor1 dot rombobeorn at comhem dot se
2005-12-10 13:26 ` laurent at guerby dot net
7 siblings, 0 replies; 9+ messages in thread
From: listor1 dot rombobeorn at comhem dot se @ 2005-12-09 22:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from listor1 dot rombobeorn at comhem dot se 2005-12-09 22:35 -------
Subject: Re: Discriminant is left uninitialized.
> But the constraint_error for "OS of A1b" looks correct, and if commented
> the one on "OS of A2b", it is a language mandated discriminant check
> failing. But may be I'm missing something, could you explain why you think
> an exception shouldn't be raised?
The discriminant check fails because OS doesn't contain any of the valid
values 0, 1 or 2 (for NT, OS2 and Linux). If there is random data in the
memory I expect a 3/256 chance that it will get a valid value.
The OS field shouldn't be random. It's fixed to Linux in the definition of
Character_Encoding_A:
This_OS : constant Known_OS := Linux;
type Character_Encoding_A (Known : Boolean := False) is
new Unified_Encoding_Record (Known => Known, OS => This_OS);
All objects of this type should therefore have OS=Linux, so the discriminant
would be valid and would pass the check.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug ada/25245] Discriminant is left uninitialized.
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
` (6 preceding siblings ...)
2005-12-09 22:35 ` listor1 dot rombobeorn at comhem dot se
@ 2005-12-10 13:26 ` laurent at guerby dot net
7 siblings, 0 replies; 9+ messages in thread
From: laurent at guerby dot net @ 2005-12-10 13:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from laurent at guerby dot net 2005-12-10 13:26 -------
Ok I now agree on both counts :).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25245
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-12-10 13:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-03 17:52 [Bug ada/25245] New: Discriminant is left uninitialized listor1 dot rombobeorn at comhem dot se
2005-12-03 17:54 ` [Bug ada/25245] " listor1 dot rombobeorn at comhem dot se
2005-12-03 17:55 ` listor1 dot rombobeorn at comhem dot se
2005-12-04 21:11 ` laurent at guerby dot net
2005-12-05 19:54 ` laurent at guerby dot net
2005-12-06 22:21 ` listor1 dot rombobeorn at comhem dot se
2005-12-09 19:51 ` laurent at guerby dot net
2005-12-09 22:35 ` listor1 dot rombobeorn at comhem dot se
2005-12-10 13:26 ` laurent at guerby dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).