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
Conversation
…@safe for accessing overlapping pointer fields in unions
Thanks for your pull request, @WalterBright! Bugzilla references
|
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. |
Now it's showing as passing AppVeyor, and now failing on semaphoreci. That looks spurious as well. |
I don't know why our CIs are so unreliable. I restarted AppVeyor and Semaphore (a few times) and all CIs are passing now. |
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
This apparently caused a regression: https://issues.dlang.org/show_bug.cgi?id=20661 |
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);
} |
…s @safe for accessing overlapping pointer fields in unions