[Issue 22329] New: DMD and LDC2 Segumentation Faults due to alias this on private field + special names
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 22 10:04:05 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22329
Issue ID: 22329
Summary: DMD and LDC2 Segumentation Faults due to alias this on
private field + special names
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: msnmancini at hotmail.com
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,"
--
More information about the Digitalmars-d-bugs
mailing list