@safe inference fundamentally broken

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 5 12:06:40 PDT 2014


On Thu, 05 Jun 2014 14:09:44 -0400
Steven Schveighoffer via Digitalmars-d <digitalmars-d at puremagic.com>
wrote:

> I propose that we start migrating towards making slicing of stack
> data un- at safe, first by making it a warning, enabled with -w. Then
> making it an error.

I reported this quite some time ago, but unfortunately, it has yet to be
fixed.

https://issues.dlang.org/show_bug.cgi?id=8838

The bizarre thing though is that in the original thread where I brought it up,
some folks fought it, arguing that it should be considered @safe. However,
slicing a static array is no different from taking the address of a local
variable, so they should definitely be treated the same.

On a related note, I very much wish that there was no implicit slicing of
static arrays in the language. It's just begging for bugs IMHO - precisely for
the same kinds of reasons that automatically converting a local variable to a
pointer to that variable would create bugs. But unfortunately, I think that
fix that now would be a very tough sell.

- Jonathan M Davis


More information about the Digitalmars-d mailing list