This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/48293] New: Legal program rejected, empty discriminant blocks object allocation with built-in-place
- From: "demoonlit at panathenaia dot halfmoon.jp" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 26 Mar 2011 07:17:34 +0000
- Subject: [Bug ada/48293] New: Legal program rejected, empty discriminant blocks object allocation with built-in-place
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48293
Summary: Legal program rejected, empty discriminant blocks
object allocation with built-in-place
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: demoonlit@panathenaia.halfmoon.jp
Created attachment 23774
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23774
minimal bug triggering source code
Compiler rejects allocating limited-type with function call (built-in-place) if
the limited type has *empty* discriminant.
(simple workaround is available, adding *dummy* discriminant)
with Ada.Finalization;
procedure min is
-- bug sample
package P1 is
type T (<>) is limited private;
function F return T;
private
type T is new Ada.Finalization.Limited_Controlled with null record;
end P1;
package body P1 is
function F return T is
begin
return (Ada.Finalization.Limited_Controlled with null record);
end F;
end P1;
X1 : P1.T := P1.T'(P1.F); -- OK
-- X2 : access P1.T := new P1.T; -- this code is illegal, it should be error.
X3 : access P1.T := new P1.T'(P1.F); -- this code is legal, but error
-- workaround
package P2 is
type T (<>) is limited private;
function F return T;
private
type T (Dummy : Integer) is new Ada.Finalization.Limited_Controlled with
null record;
-- add dummy discriminants
end P2;
package body P2 is
function F return T is
begin
return (Ada.Finalization.Limited_Controlled with Dummy => 0);
end F;
end P2;
X4 : access P2.T := new P2.T'(P2.F); -- OK
begin
null;
end min;