From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,28a755ada641b984,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!attbi_s51.POSTED!53ab2750!not-for-mail From: "Jeff C," Newsgroups: comp.lang.ada Subject: Longstanding GNAT bug, bad code, or both X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: <%7XQc.100722$eM2.38916@attbi_s51> NNTP-Posting-Host: 24.147.74.171 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s51 1091845755 24.147.74.171 (Sat, 07 Aug 2004 02:29:15 GMT) NNTP-Posting-Date: Sat, 07 Aug 2004 02:29:15 GMT Organization: Comcast Online Date: Sat, 07 Aug 2004 02:29:15 GMT Xref: g2news1.google.com comp.lang.ada:2612 Date: 2004-08-07T02:29:15+00:00 List-Id: The old Intermetrics X11 bindings have been broken since about GNAT 3.13 or so because of problems handling events from the X system.. I just verified this is still broken (solaris 2.8) in gcc 3.4.1 I believe this is due to a GNAT bug related to aliasing and incorrect assumptions. The question is this really a GNAT bug or is this code perhaps illegal. I believe I have a nice simple test case that does not even require the bindings that shows how the failure happens. Basically the problem is that we have a variant record with a default value for the discriminat at the point of the type declaration. A variable of this type is passed to a procedure via a 'access. The procedure changes the entire object in what appears to be a legal manner but when the procedure exits and the main code tries to access an element of the type that is not available for the default discriminant value, the code generates a constraint error due to a discriminant check. It seemed to me that GNAT is assuming that the variable is not changing when passed to a procedure via a 'access. This seemed like a wrong assumption I also tried it where the procedure that modifies the variable does so via an out parameter mode. Again same failure. Removing the aliased from the variable declaration fixes the problem though in that case. This seems pretty clearly to be a broken compiler issue but it has been broken for so long I find it hard to believe that this could be the case. with Text_IO; procedure Show_Bug 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 (A : access var) is begin a.all := (A => 1, Bad => 2); end see; begin declare I : aliased var; begin see(I'access); Text_IO.Put_Line(Integer'image(I.bad)); --- < Blows up here because compiler 'thinks' a = 0 but --- of course it really is 1 so it should be ok to access bad. end; end Show_Bug; Jeff Creem