Both safe and wrong?
XavierAP
n3minis-git at yahoo.es
Wed Feb 13 00:25:27 UTC 2019
On Tuesday, 12 February 2019 at 23:17:56 UTC, Olivier FAURE wrote:
>
> There would be some breakage for code with "@safe:" at the
> beginning of the file.
Only if the file contained unsafe code in initializations. And if
we consider this a bug rather than an enhancement, the code would
have been already broken. The compiler should break that code;
and it should have always detected it and generated an error.
I wouldn't think there are lots of such unsafe code hidden in
global initializations within @safe files, in Phobos or
elsewhere. And wherever there is, it should be broken.
But you could always fix it by only adding @trusted.
> Also, I don't think D compilers have any semantics for behaving
> differently depending on whether the code they're compiling is
> legacy or new code (eg already compiled code, as you put it).
> I'm guessing that those semantics would be non-trivial to
> implement.
I wouldn't add any new semantics or mechanism. If the code is
being compiled, @safe should be enforced. I was talking about the
situation where you link to binary libraries (compiled with an
old version with this bug).
Whenever (very often) dependencies are compiled from source
instead, the new errors should simply pop up and break the
compilation. This also means that at the same time this is fixed
in the compiler, any such unsafe code in Phobos should be fixed.
More information about the Digitalmars-d
mailing list