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/getprotectionbug https://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.
Comment #1 by bugzilla — 2017-12-28T05:36:09Z
Comment #2 by greeenify — 2017-12-28T10:05:51Z
@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
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/08aca45f7eee7e614956963d149218c7ab01f358 fix Issue 18030 - Segmentation fault with __traits(getProtection) on template function https://github.com/dlang/dmd/commit/7e72d7d4cb96162858804efb7725f5b2c1ad620b Merge pull request #7537 from WalterBright/fix18030 fix Issue 18030 - Segmentation fault with __traits(getProtection) on … merged-on-behalf-of: Walter Bright <[email protected]>