home bbs files messages ]

Just a sample of the Echomail archive

COMPOSVM:

<< oldest | < older | list | newer > | newest >> ]

 Message 263,777 of 264,034 
 Simon Clubley to arne@vajhoej.dk 
 Re: Unsafe code blocks 
 17 Nov 25 18:56:39 
 
From: clubley@remove_me.eisner.decus.org-Earth.UFP

On 2025-11-14, Arne Vajhøj  wrote:

These two examples _appear_ to do different things.

> $ type usaf.pas
> program usaf(input,output);
>
> var
>     c : [unsafe] char;
>
> begin
>     c := 65;
>     writeln(c);
> end.
> $ pas usaf
> $ link usaf
> $ run usaf
> A
>
> and:
>

This one appears to say that _all_ writes to the variable "c" are not
checked.

[snip]

> $ type usaf.adb
> with Unchecked_Conversion;
>
> with Ada.Text_IO, Ada.Integer_Text_IO;
>
> use Ada.Text_IO, Ada.Integer_Text_IO;
>
> procedure USaf is
>
> function i2c is new Unchecked_Conversion(Source => integer, Target =>
> character);
>
> c : character;
>
> begin
>      c := i2c(65);
>      Put(c);
>      New_Line;
> end USaf;
> $ gnat make usaf
> gcc -c usaf.adb
> usaf.adb:9:01: warning: types for unchecked conversion have different sizes
> gnatbind -x usaf.ali
> gnatlink usaf.ali
> $ run usaf
> A
>

However, with this one, you get to choose which writes to "c" are checked
by Ada. You could have Ada apply full checking to all assignments apart from
one specific problem assignment, but if I understand the above VMS Pascal
code correctly, then it's an all or nothing situation.

Have I understood the Pascal code correctly or is there something
I am missing ?

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.

--- SoupGate-Win32 v1.05
 * Origin: you cannot sedate... all the things you hate (1:229/2)

<< oldest | < older | list | newer > | newest >> ]


(c) 1994,  bbs@darkrealms.ca