Best error msg ever

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 10 17:14:03 PST 2017


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
>> `myalib.blah.morebla.foo` and `myblib.blah.morebla.foo`) 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. Just like using an uninitialized 
variable. And @safe doesn't stop you from using uninitialized variables.


More information about the Digitalmars-d mailing list