From: Maciej Sobczak on
In my previous post I had the following:

type Concrete is new Middle with null record;

function Make_Concrete return Concrete is
C : Concrete;
begin
return C;
end Make_Concrete;

I would like to return the empty(?) aggregate instead of the dummy
local variable.
Is there a way to do this?

The following:

return Concrete' (others => <>);

results in segmentation fault on my system (compiler version as
before).

Extended return with null statement works fine, but I would like to
understand the language corners involved with the aggregate.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
From: Anh Vo on
On Apr 1, 4:58 am, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote:
> In my previous post I had the following:
>
>       type Concrete is new Middle with null record;
>
>       function Make_Concrete return Concrete is
>          C : Concrete;
>       begin
>          return C;
>       end Make_Concrete;
>
> I would like to return the empty(?) aggregate instead of the dummy
> local variable.
> Is there a way to do this?
>
> The following:
>
>         return Concrete' (others => <>);
>
> results in segmentation fault on my system (compiler version as
> before).
>

Did you get seg fault during run time or the compiler crashed with seg
fault?

By the way, the return statement should be flagged as syntax error due
to missing the base type Middle.

> Extended return with null statement works fine, but I would like to
> understand the language corners involved with the aggregate.

This must me the compiler bug. The program should behave the same way.

AV
From: Dmitry A. Kazakov on
On Tue, 1 Apr 2008 04:58:06 -0700 (PDT), Maciej Sobczak wrote:

> In my previous post I had the following:
>
> type Concrete is new Middle with null record;
>
> function Make_Concrete return Concrete is
> C : Concrete;
> begin
> return C;
> end Make_Concrete;
>
> I would like to return the empty(?) aggregate instead of the dummy
> local variable.
> Is there a way to do this?

(Middle with null record);

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Robert A Duff on
Maciej Sobczak <see.my.homepage(a)gmail.com> writes:

> In my previous post I had the following:
>
> type Concrete is new Middle with null record;
>
> function Make_Concrete return Concrete is
> C : Concrete;
> begin
> return C;
> end Make_Concrete;
>
> I would like to return the empty(?) aggregate instead of the dummy
> local variable.

return (null record);

should work.

- Bob
From: Adam Beneschan on
On Apr 1, 5:54 am, Anh Vo <anhvofrc...(a)gmail.com> wrote:
> On Apr 1, 4:58 am, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote:
>
>
>
> > In my previous post I had the following:
>
> > type Concrete is new Middle with null record;
>
> > function Make_Concrete return Concrete is
> > C : Concrete;
> > begin
> > return C;
> > end Make_Concrete;
>
> > I would like to return the empty(?) aggregate instead of the dummy
> > local variable.
> > Is there a way to do this?
>
> > The following:
>
> > return Concrete' (others => <>);
>
> > results in segmentation fault on my system (compiler version as
> > before).
>
> Did you get seg fault during run time or the compiler crashed with seg
> fault?
>
> By the way, the return statement should be flagged as syntax error due
> to missing the base type Middle.

If you're talking about the last return statement:

return Concrete' (others => <>);

why would this be a syntax error? I don't know of any language rule
that would require a reference to "Middle" to be present, if that's
what you're saying.

As far as I can tell, what Maciej is trying to do is perfectly fine,
there aren't any language corners that would cause a problem, and the
compiler is misbehaving.

-- Adam

 |  Next  |  Last
Pages: 1 2 3 4
Prev: Compiler bug
Next: Newbie Questions