January 25, 2018 Re: static weirdness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, January 25, 2018 12:38:25 Kagamin via Digitalmars-d-learn wrote:
> On Thursday, 25 January 2018 at 12:06:07 UTC, Jonathan M Davis
>
> wrote:
> > Actually, assert on a pointer to a struct or a reference to a class checks for null _and_ calls the invariant, and that hasn't changed. But you have to actually assert the pointer or reference if you want to do that, and the OP didn't do that. He asserted whether it == null.
>
> I mean the compiler implicitly inserted a check like:
> struct S
> {
> auto fun()
> {
> assert(&this!=null);
> return 42;
> }
> }
AFAIK, it has never done that. Walter's stance on null pointers has always been that that's what segfaults are for, and he's against adding any additional null checks.
- Jonathan M Davis
|
January 25, 2018 Re: static weirdness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, January 25, 2018 12:42:57 Kagamin via Digitalmars-d-learn wrote:
> See https://ideone.com/VZ97dh
I don't know what's going on there. Such an assertion does not seem in line with what Walter has typically said on the subject.
Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I believe that it was complained about in that discussion, so maybe it was removed after that. Certainly, if I try that code locally with master, it runs just fine without hitting any assertions.
- Jonathan M Davis
|
January 25, 2018 Re: static weirdness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Thursday, 25 January 2018 at 12:58:12 UTC, Jonathan M Davis wrote: > Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I believe that it was complained about in that discussion, so maybe it was removed after that. Certainly, if I try that code locally with master, it runs just fine without hitting any assertions. https://dlang.org/changelog/2.077.0.html#removePreludeAssert |
January 25, 2018 Re: static weirdness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On 1/25/18 8:24 AM, Mike Parker wrote:
> On Thursday, 25 January 2018 at 12:58:12 UTC, Jonathan M Davis wrote:
>
>> Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I believe that it was complained about in that discussion, so maybe it was removed after that. Certainly, if I try that code locally with master, it runs just fine without hitting any assertions.
>
>
> https://dlang.org/changelog/2.077.0.html#removePreludeAssert
I think that changelog is wrong. The prelude assert was added I think to all member calls. And it has been removed.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation