Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 17284 - Template function attribute inference wrongly infer… #7982

Merged
merged 1 commit into from Mar 12, 2018

Conversation

WalterBright
Copy link
Member

…s @safe for accessing overlapping pointer fields in unions

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
17284 major Template function attribute inference wrongly infers @safe for accessing overlapping pointer fields in unions

@WalterBright
Copy link
Member Author

AppVeyor crashed with a linker seg fault.

@rainers
Copy link
Member

rainers commented Mar 5, 2018

AppVeyor crashed with a linker seg fault.

I tried to reproduce the crash locally with the same linker version but it worked for me. Maybe just try retriggering the build by pushing again.

@WalterBright
Copy link
Member Author

WalterBright commented Mar 5, 2018

Now it's showing as passing AppVeyor, and now failing on semaphoreci. That looks spurious as well.

@JinShil
Copy link
Contributor

JinShil commented Mar 7, 2018

I don't know why our CIs are so unreliable. I restarted AppVeyor and Semaphore (a few times) and all CIs are passing now.

@wilzbach
Copy link
Member

wilzbach commented Mar 7, 2018

SemaphoreCI needs dlang/installer#304

I can't deploy that. Only @MartinNowak can.

TEST_OUTPUT:
---
fail_compilation/test17284.d(16): Error: field `U.c` cannot access pointers in `@safe` code that overlap other fields
pure nothrow @safe void(U t)
Copy link
Member

@PetarKirov PetarKirov Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about actually verifying that attribute inference considers this function @system?
Also In the bug report me and H. S. Teoh posted several more test cases, which doesn't seem to be addressed here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about actually verifying that attribute inference considers this function @System?

The message does that.

Also In the bug report me and H. S. Teoh posted several more test cases, which doesn't seem to be addressed here.

This is the root cause. If you find more cases after this one is pulled, please point them out.

t.c = new C;
}

pragma(msg, typeof(func!U));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be converted into a static assert

@dlang-bot dlang-bot merged commit 976e82f into dlang:master Mar 12, 2018
@WalterBright WalterBright deleted the fix17284 branch March 12, 2018 19:45
@MoonlightSentinel
Copy link
Contributor

This apparently caused a regression: https://issues.dlang.org/show_bug.cgi?id=20661

@schveiguy
Copy link
Member

This also has never fixed the true issue.

This code has compiled since 2.072 (October of 2016), and segfaults:

struct UnionOf(T1, T2)
{
    union Values
    {
        T1 t1;
        T2 t2;
    }
    Values values;
    this(T1 t1)
    {
        values.t1 = t1;
    }
    T2 get()
    {
        return values.t2;
    }
}

void main() @safe
{
    alias U = UnionOf!(int, int*);
    U u;
    u = U(1);
    import std.stdio;
    writeln(*u.get);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants