Bug 22329 – DMD and LDC2 Segumentation Faults due to alias this on private field + special names
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2021-09-22T10:04:05Z
Last change time
2021-10-08T07:02:45Z
Keywords
pull
Assigned to
No Owner
Creator
Marcelo Silva Nascimento Mancini
Comments
Comment #0 by msnmancini — 2021-09-22T10:04:05Z
That causes a sigsegfault on DMD without any error message
```d
public struct Foo {
private int values;
alias values this;
}
void main()
{
writeln(Foo());
}
```
If the values variable is changed to "values2", then, a compiler error is being presented.
The mix of private and that special name causes an error, @jrfondren did a brute force test case for every word that happens: https://gist.github.com/jrfondren/78b5d366e37a6a9c4b91e37751f25789
@Mayonix helped me tracking that bug too by getting to the conclusion
"So when you name a private field some function defined in object.d, alias this it, and then pass an object to a function in a different module which attempts to access the alias this, it can't access the field in question because it's private, so instead it finds the function defined in object.d,"
Comment #1 by dlang-bot — 2021-10-03T08:26:26Z
@BorisCarvajal created dlang/dmd pull request #13119 "Fix Issue 22329 - DMD and LDC2 Segumentation Faults due to alias this" fixing this issue:
- Fix Issue 22329 - DMD and LDC2 Segumentation Faults due to alias this on private field + special names
https://github.com/dlang/dmd/pull/13119
Comment #2 by dlang-bot — 2021-10-06T04:52:53Z
dlang/dmd pull request #13119 "Fix Issue 22329 - DMD and LDC2 Segumentation Faults due to alias this" was merged into stable:
- 1a1744d58212a7a8ff431b81ffa72239acb6da3a by Boris Carvajal:
Fix Issue 22329 - DMD and LDC2 Segumentation Faults due to alias this on private field + special names
https://github.com/dlang/dmd/pull/13119
Comment #3 by dlang-bot — 2021-10-08T07:02:45Z
dlang/dmd pull request #13140 "merge stable" was merged into master:
- 138559dbf6b472674170576b09193b96d6153ab8 by Boris Carvajal:
Fix Issue 22329 - DMD and LDC2 Segumentation Faults due to alias this on private field + special names (#13119)
https://github.com/dlang/dmd/pull/13140