[Bug ada/29015] Ada 2005 observer pattern with mutually dependent packages and containers produces compiler error

ludovic at ludovic-brenta dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 9 20:11:00 GMT 2008



------- Comment #6 from ludovic at ludovic-brenta dot org  2008-04-09 20:10 -------
Reduced test case:

package Observers is
  type Observer is tagged null record;
  type Observer_Access is access all Observers.Observer'Class;
end Observers;

limited with Observers;
with Ada.Containers.Doubly_Linked_Lists;
package Subjects is
  function Equals(Left, Right : access Observers.Observer) return Boolean;
  package Observer_Lists is new
    Ada.Containers.Doubly_Linked_Lists(Observers.Observer_Access, Equals);
end Subjects;

with Observers; -- this line triggers the bug
package body Subjects is
   function Equals(Left, Right : access Observers.Observer) return Boolean is
   begin
      return False;
   end Equals;
end Subjects;

With the line that triggers the bug:

gcc-4.1 -c -gnat05 subjects.adb
+===========================GNAT BUG DETECTED==============================+
| 4.1.3 20070518 (prerelease) (Debian 4.1.2-8) (x86_64-pc-linux-gnu)       |
| Assert_Failure atree.adb:812                                             |
| Error detected at subjects.ads:8:3                                       |

gcc-4.3 -c -gnat05 subjects.adb
+===========================GNAT BUG DETECTED==============================+
| 4.3.1 20080401 (prerelease) (x86_64-pc-linux-gnu) Assert_Failure
atree.adb:886|
| Error detected at subjects.ads:8:3                                       |


Without the line that triggers the bug:

gcc-4.1 -c -gnat05 subjects.adb
subjects.ads:9:49: premature use of incomplete type
subjects.ads:9:49: instantiation abandoned

gcc-4.3 -c -gnat05 subjects.adb
subjects.ads:9:49: premature use of incomplete type
subjects.ads:9:49: instantiation abandoned


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29015



More information about the Gcc-bugs mailing list