[Issue 22209] New: NRVO variable detection ignoring `alias this` conversion => segfaults
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 14 04:19:17 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22209
Issue ID: 22209
Summary: NRVO variable detection ignoring `alias this`
conversion => segfaults
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kinke at gmx.net
This segfaults at runtime (for all versions currently on run.dlang.io):
```
struct U { size_t[4] a; }
struct S
{
int x;
U u;
alias u this;
}
U foo()
{
S s = S(42, U([1, 2, 3, 4]));
return s;
}
void main()
{
assert(foo().a[0] == 1);
}
```
It's apparently caused by the frontend wrongly marking `s` in `foo()` as the
NRVO variable (FuncDeclaration.nrvo_var), ignoring that it requires an implicit
conversion via `alias this` - return type and variable type clearly differ.
--
More information about the Digitalmars-d-bugs
mailing list