Bug 18030 – Segmentation fault with __traits(getProtection) on template function.
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-04T12:14:42Z
Last change time
2017-12-30T05:37:03Z
Keywords
ice
Assigned to
No Owner
Creator
dmdreport123
Comments
Comment #0 by dmdreport123 — 2017-12-04T12:14:42Z
The following code causes dmd to crash with a segmentation fault:
----
struct S(T)
{
T var;
pragma(
msg,
"Inside S: func() is ",
__traits(getProtection, __traits(getMember, T, "func"))
);
}
class C
{
alias Al = S!C;
static int func(U)(U var)
{
return 123;
}
pragma(
msg,
"Inside C: func() is ",
__traits(getProtection, __traits(getMember, C, "func"))
)
}
void main() {}
----
$ dmd app.d
Inside S: func() is Segmentation fault
----
This error first appeared in dmd2.075.
Here is a simple test project on github and tests results from travis-ci.
https://github.com/Betelgeyser/getprotectionbughttps://travis-ci.org/Betelgeyser/getprotectionbug
If C.func() has no template parameters or __traits(getProtection) is not called inside struct S, then the code compiles. Calling __traits(getProtection) inside class C does not result in a segfault. Whether S and C are classes or structs does not affect this error.
@dmdreport123: thanks a lot for creating the GitHub repository and Travis integration, but the reduced test case is a lot better. This is just to avoid unnecessary work in the future.
Comment #3 by github-bugzilla — 2017-12-30T05:37:02Z