Getting action on your favorite D issues
Steven Schveighoffer
schveiguy at gmail.com
Sat Jun 6 22:01:51 UTC 2020
On 6/6/20 5:38 PM, Joseph Rushton Wakeling wrote:
> On Saturday, 6 June 2020 at 21:01:05 UTC, Steven Schveighoffer wrote:
>> The individual fields could have (possibly UFCS) trusted semantics
>> that are invalid when you arbitrarily set the data.
>
> Doesn't that also apply to void-initialized values in the case that the
> implementation allows arbitrary bit-patterns (what IIUC the C99 standard
> calls trap values)?
Yes, it's the same thing. This is why I specifically said that the case of:
int x = void;
won't corrupt memory *as long as everything that uses it is @safe*. This
is due to the fact that all indexing operations in @safe code are
bounds-checked.
As soon as you start using @trusted, then the semantic meaning of what x
actually represents comes into play.
The thing we *should* do is just disallow all these corner cases in
@safe code. It's much easier to relax it in certain cases later than it
is to add on band-aids for all the bad cases.
I don't think the code breakage would be tolerable for many people. Then
again, maybe void initialization isn't common enough to cause a lot of
breakage, I don't know. But I'm sure union usage is higher.
-Steve
More information about the Digitalmars-d
mailing list