comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Re: Strict aliasing, is it OK?
Date: Wed, 05 Jul 2017 02:39:58 +0300
Date: 2017-07-05T02:39:58+03:00	[thread overview]
Message-ID: <ojh91a$3dp$1@gioia.aioe.org> (raw)
In-Reply-To: lya84j3mn7.fsf@pushface.org

Simon Wright wrote:

> Victor Porton <porton@narod.ru> writes:
> 
>>    type My_Dummy_Access is access constant RDF.Auxiliary.Dummy_Record;
>>
>>    function C_Raptor_Parser_Get_Description (Parser: Handle_Type) return
>>    My_Dummy_Access
>>       with Import, Convention=>C,
>>       External_Name=>"raptor_parser_get_description";
>>
>>    function Get_Description (Parser: Parser_Type) return
>>    RDF.Raptor.Syntaxes.Syntax_Description_Type is
>>       function Conv is new Ada.Unchecked_Conversion(My_Dummy_Access,
>>       RDF.Raptor.Syntaxes.Syntax_Description_Type);
> 
> (I _wish_ you could use shorter lines!)
> 
> Is an "RDF.Raptor.Syntaxes.Syntax_Description_Type" actually an "access
> constant RDF.Auxiliary.Dummy_Record"? If so, why not just declare
> C_Raptor_Parser_Get_Description as returning a
> RDF.Raptor.Syntaxes.Syntax_Description_Type? And if not, what are you
> doing returning an unchecked conversion of one to the other?

Yes, I already found that this can be simplified (and updated my code at 
GitHub).

But my question about my old code remains valid. Is that old code erroneous 
or isn't?

By the way,

type Syntax_Description_Type is access constant Syntax_Description_Record
     with Convention => C;

This isn't `access constant RDF.Auxiliary.Dummy_Record` but is memory 
compatible with it.

> Your code as it stands is equivalent to
> 
>    function C_Raptor_Parser_Get_Description
>      (Parser : Handle_Type)
>      return RDF.Raptor.Syntaxes.Syntax_Description_Type
>       with
>         Import,
>         Convention => C,
>         External_Name => "raptor_parser_get_description";
-- 
Victor Porton - http://portonvictor.org


  reply	other threads:[~2017-07-04 23:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 17:49 Strict aliasing, is it OK? Victor Porton
2017-07-04 17:50 ` Victor Porton
2017-07-04 18:06 ` Victor Porton
2017-07-04 18:15 ` Niklas Holsti
2017-07-04 18:30   ` Victor Porton
2017-07-04 19:29     ` Niklas Holsti
2017-07-04 20:11       ` Victor Porton
2017-07-04 20:13         ` Victor Porton
2017-07-04 21:41 ` Simon Wright
2017-07-04 23:39   ` Victor Porton [this message]
2017-07-05  9:49     ` Simon Wright
2017-07-08 17:29     ` Robert Eachus
replies disabled

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