Bug 20608 – [REG2.087] Cannot pass tuple.expand to auto ref T... template argument pack
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-25T18:30:03Z
Last change time
2020-09-25T09:46:16Z
Keywords
industry, pull, rejects-valid
Assigned to
No Owner
Creator
johanengelen
Comments
Comment #0 by johanengelen — 2020-02-25T18:30:03Z
Testcase:
```
void foo(T...)(auto ref T args) {}
void main() {
import std.typecons;
enum tup = tuple(1,"jojo");
foo(tup.expand); // line 6
}
```
This errors with DMD >= 2.087 with:
onlineapp.d(6): Error: cannot modify constant expression `Tuple(1, "jojo").__expand_field_0`
Comment #1 by moonlightsentinel — 2020-06-05T14:35:40Z
Digger:
commit e268d8301979b2f1f83b4565a20ef1387ba34396
Author: The Dlang Bot <[email protected]>
Date: Sun Jul 7 10:14:29 2019 +0200
dmd: Merge pull request #10115 from Basile-z/issue-20011-17828
https://github.com/dlang/dmd/pull/10115
fix issue 20011, 17828 - crash or accept write operation on members of manifest constant structs
merged-on-behalf-of: Walter Bright <[email protected]>
Comment #2 by moonlightsentinel — 2020-06-05T15:13:45Z
Digger:
commit e268d8301979b2f1f83b4565a20ef1387ba34396
Author: The Dlang Bot <[email protected]>
Date: Sun Jul 7 10:14:29 2019 +0200
dmd: Merge pull request #10115 from Basile-z/issue-20011-17828
https://github.com/dlang/dmd/pull/10115
fix issue 20011, 17828 - crash or accept write operation on members of manifest constant structs
merged-on-behalf-of: Walter Bright <[email protected]>
Comment #3 by moonlightsentinel — 2020-06-05T15:14:30Z
Reduced example:
void foo(T...)(auto ref T args) {}
void main()
{
enum tup = Tuple();
foo(tup.expand); // line 6
}
struct Tuple
{
int expand;
}
foo should probably infer non-ref for enums.
Comment #4 by dlang-bot — 2020-09-02T21:50:57Z
@kinke updated dlang/dmd pull request #10124 "Fix Issue 19754 - Re-apply #9505 and fix it, making isLvalue() logic more restrictive wrt. literals" fixing this issue:
- Fix Issue 20608 - Revert (obsolete and problematic) #10115
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
https://github.com/dlang/dmd/pull/10124
Comment #5 by dlang-bot — 2020-09-25T09:46:16Z
dlang/dmd pull request #10124 "Fix Issue 19754 - Re-apply #9505 and fix it, making isLvalue() logic more restrictive wrt. literals" was merged into master:
- eddb064ba44d2aeed527396184b40ea37169e80d by Martin Kinkelin:
Fix Issue 20608 - Revert (obsolete and problematic) #10115
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
https://github.com/dlang/dmd/pull/10124