comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff C," <jcreem@yahoo.com>
Subject: Re: Longstanding GNAT bug, bad code, or both
Date: Sat, 07 Aug 2004 04:05:21 GMT
Date: 2004-08-07T04:05:21+00:00	[thread overview]
Message-ID: <5yYQc.102027$eM2.62394@attbi_s51> (raw)
In-Reply-To: %7XQc.100722$eM2.38916@attbi_s51

Ok..Original post was still a bit confused and pointed to the wrong
line...but the problem is still real.

I've decided this really is a longstanding GNAT bug so I created a bugzilla
report. If someone
can tell me that the code is not legal Ada then I'll cancel the report.


--- Here is what the bugzilla now says


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;





  reply	other threads:[~2004-08-07  4:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-07  2:29 Longstanding GNAT bug, bad code, or both Jeff C,
2004-08-07  4:05 ` Jeff C, [this message]
2004-08-07 15:23   ` Stephen Leake
2004-08-07 14:07 ` Longstanding GNAT bug, bad code, or both -- Answer..Bad code Jeff C,
2004-08-07 16:44   ` Stephen Leake
2004-08-08 11:26     ` Simon Wright
2004-08-24 20:57     ` Randy Brukardt
2004-08-25 11:00       ` Jeff C,
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox