Bug 20779 – Segfault when self-containing struct is accessed from inside in a __traits(compiles) context
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-04-28T08:58:05Z
Last change time
2020-04-28T10:42:15Z
Keywords
pull
Assigned to
No Owner
Creator
FeepingCreature
Comments
Comment #0 by default_357-line — 2020-04-28T08:58:05Z
Consider this code:
struct X {
X x;
enum e = __traits(compiles, X.init);
}
DMD tries to warn us that X cannot contain itself as a field; however, the error is eaten by the __traits(compiles). Then it segfaults.
Comment #1 by dlang-bot — 2020-04-28T09:31:00Z
@FeepingCreature created dlang/dmd pull request #11070 "Fix issue 20779: compiler segfaults when struct contains itself" fixing this issue:
- Fix issue 20779: compiler segfaults when struct contains itself
When working with metaprogramming, the error message saying that the
struct should not contain itself can get swallowed by gagging.
In this case, only the segfault remains, leading to an unsatisfactory
user experience. Fix the segfault by breaking the infinite recursion.
https://github.com/dlang/dmd/pull/11070
Comment #2 by dlang-bot — 2020-04-28T10:42:15Z
dlang/dmd pull request #11070 "Fix issue 20779: compiler segfaults when struct contains itself" was merged into stable:
- cf4c82efdadfc74c1973f66a16254ec886380c20 by Mathis Beer:
Fix issue 20779: compiler segfaults when struct contains itself
When working with metaprogramming, the error message saying that the
struct should not contain itself can get swallowed by gagging.
In this case, only the segfault remains, leading to an unsatisfactory
user experience. Fix the segfault by breaking the infinite recursion.
https://github.com/dlang/dmd/pull/11070