[Bug ada/16910] New: Incorrect code generated for certain variant record source
jeff at thecreems dot com
gcc-bugzilla@gcc.gnu.org
Sat Aug 7 04:03:00 GMT 2004
I believe there is a longstanding bug that has been present in GNAT since about
GNAT 3.13. The old intermetrics Xlib Ada bindings stopped working at that time
and it seemed to be related to the processing of the XEvent variant records. I
have created a very small test program that think demonstrates the same failure
mode.
The problem appears to be that if a variable that is a variant record is
declared as aliased, some of the constraint checking logic fails in such a way
that it relies on the default value of the discriminant rather than the current
value.
This program demonstrates the problem both on Solaris and Windows XP
using gcc 3.4.1
with Text_Io;
procedure Aaa is
type Var (A : Integer:=0) is
record
case A is
when 0 =>
Ok : Integer;
when 1 =>
Bad : Integer;
when others =>
null;
end case;
end record;
procedure See (
X : in out Var ) is
begin
--
-- The following will blow up with a discriminant
-- check error (contraint_error) when the actual parameter
-- associated with X is declared aliased. Note that
-- in this code I realize there is no good reason to
-- declare it as aliased however this still effectively
-- shows the problem.
--
X:= (
A => 1,
Bad => 2);
end See;
begin
declare
I : aliased Var; -- If you make this not aliased, everything works fine
--I : Var;
begin
See(I);
Text_Io.Put_Line(Integer'Image(I.Bad));
end;
end Aaa;
--
Summary: Incorrect code generated for certain variant record
source
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jeff at thecreems dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16910
More information about the Gcc-bugs
mailing list