Best error msg ever

Walter Bright via Digitalmars-d digitalmars-d at
Fri Feb 10 21:19:37 PST 2017

On 2/10/2017 5:14 PM, Chris Wright wrote:
> On Fri, 10 Feb 2017 12:32:19 -0800, Walter Bright wrote:
>> On 2/10/2017 4:41 AM, Nemanja Boric wrote:
>>> I saw it happen with D as well: everything compiles, everything is
>>> fine, and suddenly segfault. The issue was caused by template argument,
>>> two modules with the same name, but from different packages (think
>>> `` and ``) and a cast
>>> somewhere in the middle of the callstack which casted the first
>>> template argument to the second one, where the `myalib`'s foo was
>>> casted to `myblib`'s interface.
>> That's why such casts are not allowed in @safe code.
> I'm a bit surprised by that. In @system code, you can cast, and it results
> in a null pointer. A well-known value.

It depends on just what is being cast. If you're casting an interface to an 
Object, it is not allowed in @safe code because not all interfaces are Objects, 
and this is not reliably detectable at runtime.

> And @safe doesn't stop you from using uninitialized variables.

As shown, it does.

More information about the Digitalmars-d mailing list