* Impressively difficult to compile code for GNAT
@ 2009-11-21 16:36 gcc
2009-11-21 16:51 ` gcc
2009-11-22 21:31 ` Eric Botcazou
0 siblings, 2 replies; 6+ messages in thread
From: gcc @ 2009-11-21 16:36 UTC (permalink / raw)
To: gcc
Hello.
I'm working on a small project to create an abstraction over directories
and archives. I've managed to write some code that seems simple enough
(using tagged limited types) and even though the code appears to be valid,
it seems to either trigger bugs in the runtime (causing crashes on execution)
or fails to compile:
Both Debian GCC 4.3, GNAT GPL 2009 and FreeBSD GCC 4.4 fail with the following:
pfseudo-archiver-directory.adb:24:41: wrong type for return_subtype_indication
pfseudo-archiver-directory.adb:46:35: wrong type for return_subtype_indication
GCC SVN (r154285) fails to build with a strange error:
arc_dir_003.adb:25:32: "_master" conflicts with declaration at line 21
The output of -gnatG shows this error to be apparently incorrect:
error := false;
B_1 : declare
_master : constant integer := system__soft_links__current_master.all;
A6bM : integer renames _master;
type A6b is access all pfseudo__archiver__Tarchive_tC;
R7b : A6b := pfseudo__archiver__directory.
The code is available here:
http://git.coreland.ath.cx/gitweb.cgi?p=pfseudo/.git;a=summary
$ git clone http://git.coreland.ath.cx/pfseudo/.git
Configure and build with:
$ echo 'gcc' > conf-adacomp
$ echo 'gnatbind' > conf-adabind
$ echo 'gnatlink' > conf-adalink
$ make
$ make tests
Regards,
M
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Impressively difficult to compile code for GNAT
2009-11-21 16:36 Impressively difficult to compile code for GNAT gcc
@ 2009-11-21 16:51 ` gcc
2009-11-21 17:10 ` Robert Dewar
2009-11-22 5:24 ` gcc
2009-11-22 21:31 ` Eric Botcazou
1 sibling, 2 replies; 6+ messages in thread
From: gcc @ 2009-11-21 16:51 UTC (permalink / raw)
To: gcc
Here's another case from a prototype that causes a crash on GCC 4.4
but, ironically, gives every impression of compiling and running
on earlier versions (4.3, GPL 2009):
with Ada.Streams.Stream_IO;
with Ada.Finalization;
package Archiver is
type Archiver_t is tagged limited private;
type Archive_t is tagged limited private;
function Open_Archive
(Archiver : in Archiver_t;
Path : in String) return Archive_t'Class;
function Stream
(Archive : in Archive_t)
return Ada.Streams.Stream_IO.Stream_Access;
private
package Stream_IO renames Ada.Streams.Stream_IO;
type Archiver_t is tagged limited null record;
type Archive_t is new Ada.Finalization.Limited_Controlled with record
Name : access String;
File : Stream_IO.File_Type;
end record;
end Archiver;
package body Archiver is
function Open_Archive
(Archiver : in Archiver_t;
Path : in String) return Archive_t'Class
is
pragma Unreferenced (Archiver);
begin
-- This line causes a segmentation fault.
return A : Archive_t'Class := Archive_t'(Ada.Finalization.Limited_Controlled with others => <>) do
A.Name := new String'(Path);
Stream_IO.Open
(Name => A.Name.all,
File => A.File,
Mode => Stream_IO.In_File);
end return;
end Open_Archive;
function Stream
(Archive : in Archive_t)
return Ada.Streams.Stream_IO.Stream_Access is
begin
return Stream_IO.Stream (Archive.File);
end Stream;
end Archiver;
with Ada.Text_IO;
with Ada.Streams.Stream_IO;
with Archiver;
procedure Main is
A : Archiver.Archiver_t;
S : constant Ada.Streams.Stream_IO.Stream_Access := Archiver.Stream (Archiver.Open_Archive (A, "file.zip"));
X : Integer;
begin
X := Integer'Input (S);
Ada.Text_IO.Put_Line (Integer'Image (X));
end Main;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Impressively difficult to compile code for GNAT
2009-11-21 16:51 ` gcc
@ 2009-11-21 17:10 ` Robert Dewar
2009-11-22 4:57 ` gcc
2009-11-22 5:24 ` gcc
1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 2009-11-21 17:10 UTC (permalink / raw)
To: gcc; +Cc: gcc
By the way, a general note is that it is usually a good
idea to stay away from anonymous access types, since
for one thing, there are real issues in freeing them.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Impressively difficult to compile code for GNAT
2009-11-21 17:10 ` Robert Dewar
@ 2009-11-22 4:57 ` gcc
0 siblings, 0 replies; 6+ messages in thread
From: gcc @ 2009-11-22 4:57 UTC (permalink / raw)
To: Robert Dewar; +Cc: gcc
On 2009-11-21 12:09:11, Robert Dewar wrote:
> By the way, a general note is that it is usually a good
> idea to stay away from anonymous access types, since
> for one thing, there are real issues in freeing them.
Agreed, yes.
In the real project, the String_Access types from the unbounded
strings package was used.
Regards,
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Impressively difficult to compile code for GNAT
2009-11-21 16:51 ` gcc
2009-11-21 17:10 ` Robert Dewar
@ 2009-11-22 5:24 ` gcc
1 sibling, 0 replies; 6+ messages in thread
From: gcc @ 2009-11-22 5:24 UTC (permalink / raw)
To: gcc
Bug filed here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Impressively difficult to compile code for GNAT
2009-11-21 16:36 Impressively difficult to compile code for GNAT gcc
2009-11-21 16:51 ` gcc
@ 2009-11-22 21:31 ` Eric Botcazou
1 sibling, 0 replies; 6+ messages in thread
From: Eric Botcazou @ 2009-11-22 21:31 UTC (permalink / raw)
To: gcc; +Cc: gcc
> The code is available here:
>
> http://git.coreland.ath.cx/gitweb.cgi?p=pfseudo/.git;a=summary
> $ git clone http://git.coreland.ath.cx/pfseudo/.git
See http://gcc.gnu.org/bugs for instructions on how to report bugs.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-22 21:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-21 16:36 Impressively difficult to compile code for GNAT gcc
2009-11-21 16:51 ` gcc
2009-11-21 17:10 ` Robert Dewar
2009-11-22 4:57 ` gcc
2009-11-22 5:24 ` gcc
2009-11-22 21:31 ` Eric Botcazou
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).