GNAT BUG on access procedure parameter in protected type entry

Posted on 2011-05-25

I already mentioned that i don’t like Ada, but I didn’t expect to hit something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ gnatmake gnatbug
gcc-4.4 -c gnatbug.adb
+===========================GNAT BUG DETECTED==============================+
| 4.4.6 (x86_64-pc-linux-gnu) Assert_Failure sem_ch3.adb:1063              |
| Error detected at gnatbug.adb:3:17                                       |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc-4.4 or gnatmake command that you entered.          |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.

gnatbug.adb
gnatbug.ads

compilation abandoned
gnatmake: "gnatbug.adb" compilation error

So GNAT doesn’t like “access procedure” parameters in entries for protected types. As I’m hiding the protected types anyway and there is no need to protect the object while running the callback I was able to workaround it: calling the entry, then the callback, and then a cleanup procedure…

Here the simplified testcase sources, which I also provided to the upstream bug: Bug 49164 – GNAT BUG on access procedure parameter in protected type entry

gnatbug.ads:

1
2
3
4
5
6
7
package Gnatbug is
   protected type X is
      entry Foo (Bar : access procedure);
   private
      Member : Integer := 0;
   end X;
end Gnatbug;

gnatbug.adb:

1
2
3
4
5
6
7
8
9
package body Gnatbug is
   protected body X is
      entry Foo (Bar : access procedure)
        when Member = 0 is
      begin
         Bar.all;
      end;
   end X;
end Gnatbug;

Generated using nanoc and bootstrap - Last content change: 2013-08-16 14:47