comp.lang.ada
 help / color / mirror / Atom feed
* Strange instantiation error with formal packages
@ 2013-11-19  5:57 ytomino
  2013-11-19 15:08 ` AdaMagica
  0 siblings, 1 reply; 6+ messages in thread
From: ytomino @ 2013-11-19  5:57 UTC (permalink / raw)


Hello.
Please, consider below example:

---- 8< ----

with ada.containers.ordered_sets; -- any generic package
with g1;
with g2;
procedure main is
   package charsets is new ada.containers.ordered_sets (Character);
   package p1 is new g1 (charsets);
   package p1_n is new p1.nested;
   package p2 is new g2 (charsets, p1, p1_n);
begin
   null;
end main;

with ada.containers.ordered_sets;
generic
   with package sets is new ada.containers.ordered_sets(<>);
package g1 is
   generic
   package nested is
   end nested;
end g1;

with ada.containers.ordered_sets;
with g1;
generic
   with package sets is new ada.containers.ordered_sets(<>); -- *1
   with package p1 is new g1 (sets);
   with package p1_n is new p1.nested;
package g2 is
end g2;

---- >8 ----

This is OK, able to be compiled.

$ gnatmake -gnat2012 main.adb
gcc -c -gnat2012 main.adb
gcc -c -gnat2012 g1.ads
gcc -c -gnat2012 g2.ads
gnatbind -x main.ali
gnatlink main.ali

Then...
Remove the formal package "sets" from g2:

---- 8< ----

with ada.containers.ordered_sets;
with g1;
with g2;
procedure main is
   package charsets is new ada.containers.ordered_sets (Character);
   package p1 is new g1 (charsets);
   package p1_n is new p1.nested;
   package p2 is new g2 (p1, p1_n); -- "sets" is removed
begin
   null;
end main;

-- g1 is same as first example.

with g1;
generic
   -- "sets" is removed
   with package p1 is new g1 (<>); -- use a box instead of "sets"
   with package p1_n is new p1.nested;
package g2 is
end g2;

---- >8 ----

This is bad.

$ gnatmake -gnat2012 main.adb
gcc -c -gnat2012 main.adb
main.adb:8:30: actual parameter must be instance of "nested"
main.adb:8:30: instantiation abandoned
gnatmake: "main.adb" compilation error

Why?

I tried with gcc-4.8.1 and GNAT GPL 2012.


Regards.

--
Yuta Tomino

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange instantiation error with formal packages
  2013-11-19  5:57 Strange instantiation error with formal packages ytomino
@ 2013-11-19 15:08 ` AdaMagica
  2013-11-19 15:45   ` Adam Beneschan
  0 siblings, 1 reply; 6+ messages in thread
From: AdaMagica @ 2013-11-19 15:08 UTC (permalink / raw)


Hm, the code looks OK. Unfortunatly I have no other compiler to try (are there currently any others for Ada 2012?)

I suggest writing a problem report.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange instantiation error with formal packages
  2013-11-19 15:08 ` AdaMagica
@ 2013-11-19 15:45   ` Adam Beneschan
  2013-11-19 20:14     ` Dmitry A. Kazakov
  2013-11-21 13:54     ` ytomino
  0 siblings, 2 replies; 6+ messages in thread
From: Adam Beneschan @ 2013-11-19 15:45 UTC (permalink / raw)


On Tuesday, November 19, 2013 7:08:09 AM UTC-8, AdaMagica wrote:
> Hm, the code looks OK. Unfortunatly I have no other compiler to try (are there currently any others for Ada 2012?)
> 
> 
> 
> I suggest writing a problem report.

It doesn't need to be an Ada 2012 compiler; this code has only Ada 95 features.  I just tried it on a different compiler and it compiles fine; furthermore, I don't see any errors in the code.  I don't believe that there were any changes to Ada 2012 that would turn this kind of legal code into illegal code.  (They try hard to maintain backward compatibility.)  And in any case, GNAT gets the same error in gnat2005 mode.  So this definitely appears to be a compiler bug.

                                    -- Adam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange instantiation error with formal packages
  2013-11-19 15:45   ` Adam Beneschan
@ 2013-11-19 20:14     ` Dmitry A. Kazakov
  2013-11-21 14:05       ` ytomino
  2013-11-21 13:54     ` ytomino
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2013-11-19 20:14 UTC (permalink / raw)


On Tue, 19 Nov 2013 07:45:37 -0800 (PST), Adam Beneschan wrote:

> And in any case, GNAT gets the same error in gnat2005 mode.  So this
> definitely appears to be a compiler bug.

4.8 appears to be more buggy than 4.7. It introduced new bugs in inherited
operations and generics (always generics). The OP could try switching back
to 4.7 or 4.6.

P.S. Some bugs vanish when dotted notation is replaced with functional
call. E.g.

   F (X.all, Y) instead of X.F (Y)

When X is a class-wide access type.

It would be nice if AdaCore improved diagnostics on compiler crash (when
GNAT BUG DETECTED box pops up).

One method of working GNAT bugs around is to comment out everything until
the compiler stops crashing in order to find the offending place.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange instantiation error with formal packages
  2013-11-19 15:45   ` Adam Beneschan
  2013-11-19 20:14     ` Dmitry A. Kazakov
@ 2013-11-21 13:54     ` ytomino
  1 sibling, 0 replies; 6+ messages in thread
From: ytomino @ 2013-11-21 13:54 UTC (permalink / raw)


On Wednesday, November 20, 2013 12:45:37 AM UTC+9, Adam Beneschan wrote:
> On Tuesday, November 19, 2013 7:08:09 AM UTC-8, AdaMagica wrote:
> 
> > Hm, the code looks OK. Unfortunatly I have no other compiler to try (are there currently any others for Ada 2012?)
> >
> > I suggest writing a problem report.
> 
> 
> 
> It doesn't need to be an Ada 2012 compiler; this code has only Ada 95 features.  I just tried it on a different compiler and it compiles fine; furthermore, I don't see any errors in the code.  I don't believe that there were any changes to Ada 2012 that would turn this kind of legal code into illegal code.  (They try hard to maintain backward compatibility.)  And in any case, GNAT gets the same error in gnat2005 mode.  So this definitely appears to be a compiler bug.
> 
>                                     -- Adam

Thank you AdaMagica and Adam.
I tried it with -gnat95 and -gnat05, got same results, and reported it. 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59234

(But I'm worried about gcc's bugzilla. I've seen several times that some bugs were reported into the bugzilla from comp.lang.ada. However,  Does the most part of them seem ignored? :-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange instantiation error with formal packages
  2013-11-19 20:14     ` Dmitry A. Kazakov
@ 2013-11-21 14:05       ` ytomino
  0 siblings, 0 replies; 6+ messages in thread
From: ytomino @ 2013-11-21 14:05 UTC (permalink / raw)


On Wednesday, November 20, 2013 5:14:32 AM UTC+9, Dmitry A. Kazakov wrote:
> 
> 4.8 appears to be more buggy than 4.7. It introduced new bugs in inherited
> operations and generics (always generics). The OP could try switching back
> to 4.7 or 4.6.
> 

I tried it with gcc-4.7.2.
The result is same.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-21 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19  5:57 Strange instantiation error with formal packages ytomino
2013-11-19 15:08 ` AdaMagica
2013-11-19 15:45   ` Adam Beneschan
2013-11-19 20:14     ` Dmitry A. Kazakov
2013-11-21 14:05       ` ytomino
2013-11-21 13:54     ` ytomino

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