[M3devel] subranges 0..-1?

Mika Nystrom mika at async.async.caltech.edu
Mon Oct 4 23:16:27 CEST 2010


Of course unsafe code matters.

But does the particular example of unsafe code (ADR of a zero-sized
object) matter?  No, because:

1. For human-written code we use your argument.  "Don't do that"

2. Don't generate UNSAFE code by machine.  Or if you must be as careful
   as implied by 1.

     Mika

Jay K writes:
>
>So=2C I'm not supposed to worry about unsafe stuff..including if the backen=
>d and debugging information can=A0 handle it? No.
>Unsafe code matters=2C a lot.
>
>=A0- Jay
>
>----------------------------------------
>> To: jay.krell at cornell.edu
>> Date: Mon=2C 4 Oct 2010 11:12:08 -0700
>> From: mika at async.async.caltech.edu
>> CC: m3devel at elegosoft.com
>> Subject: Re: [M3devel] subranges 0..-1?
>>
>> Jay K writes:
>> >
>> >It worries me somewhat that we allow zero-sized types.
>> >Including TYPE Foo =3D3D RECORD END=3D3B
>> >It is reassuring to me that C and C++ doesn't have these.
>> >I don't want to think about what they mean.
>> >Do they make sense to others?
>>
>> Yes=2C they make a lot of sense. Not having them means special-casing
>> any program that generates code. Obviously a correct program that generat=
>es
>> code including a zero-sized array will never generate an expression
>> that indexes such an array...
>>
>> >
>> >C requires a field. C++ adds a dummy one internally=3D2C that it can/mus=
>t try
>> >to optimize away when inheritance is involved but still.
>> >
>> >
>> >C++ is interested in the property of pointers not being equal=3D2C like:
>> >
>> >TYPE T1 =3D3D RECORD END=3D3B
>> >TYPE T2 =3D3D RECORD a=3D2Cb:T1 END=3D3B
>> >
>> >VAR a:T1=3D3B
>> >ADR(a.b) # ADR(a.a.)=3D3B
>> >
>> >But in Modula-3 they would have the same address.
>> >What does it mean to take the address of something that doesn't exist?
>> >Perhaps it isn't allowed?
>>
>> This is UNSAFE code=2C so it means whatever the implementation makes
>> it mean=2C including (as far as I'm concerned) a compiler crash=2C if
>> that is the easiest thing you can make it mean. I really wouldn't
>> worry about the UNSAFE parts of Modula-3 that much... expected to be
>> implementation-dependent. Although I admit it would be better to have
>> it do something meaningless in this case. Since T1 is an empty type
>> there's not much you can do with the address anyhow.
>>
>> Mika
> 		 	   		  =



More information about the M3devel mailing list