Bug 22300 – [REG 2.098-rc.2] `-checkaction=context` of a `shared` type with an `opCast` fails to compile
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-13T08:22:29Z
Last change time
2021-11-08T15:54:14Z
Keywords
pull
Assigned to
No Owner
Creator
Mathias LANG
Comments
Comment #0 by pro.mathias.lang — 2021-09-13T08:22:29Z
```
struct Fail
{
int value;
@safe pure nothrow @nogc:
bool opCast () shared const scope { return true; }
}
void main ()
{
assert(shared(Fail).init);
}
```
Compiled with `~/dlang/ldc-36198b36/bin/ldc2 -checkaction=context -run wat.d`:
```
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(194): Error: cannot implicitly convert expression `v.opCast()` of type `bool` to `const(Fail)`
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(527): Error: template instance `core.internal.dassert.miniFormat!(shared(Fail))` error instantiating
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(44): instantiated from here: `miniFormatFakeAttributes!(shared(Fail))`
wat.d(11): instantiated from here: `_d_assert_fail!(shared(Fail))`
```
Worked fine in v2.097.0. Affects vibe-core so it's pretty serious.
Comment #1 by dlang-bot — 2021-10-19T13:00:13Z
@MoonlightSentinel created dlang/dmd pull request #13203 "Issue 22300 - Allow shared <-> unshared reinterpreting casts during CTFE" mentioning this issue:
- Issue 22300 - Allow shared <-> unshared reinterpreting casts during CTFE
CTFE evaluation is single threaded only, hence it's safe to discard the
`shared` qualifier in a reinterpreting cast.
This change allows `-checkaction=context` to use a reinterpreting cast
for compile and runtime - which removes the problematic workaround
that caused the regression.
https://github.com/dlang/dmd/pull/13203
Comment #2 by dlang-bot — 2021-10-20T03:48:07Z
dlang/dmd pull request #13203 "Issue 22300 - Allow shared <-> unshared reinterpreting casts during CTFE" was merged into stable:
- 80a4215978914d1860263da89884e6799679b36e by MoonlightSentinel:
Issue 22300 - Allow shared <-> unshared reinterpreting casts during CTFE
CTFE evaluation is single threaded only, hence it's safe to discard the
`shared` qualifier in a reinterpreting cast.
This change allows `-checkaction=context` to use a reinterpreting cast
for compile and runtime - which removes the problematic workaround
that caused the regression.
https://github.com/dlang/dmd/pull/13203
Comment #3 by dlang-bot — 2021-10-20T08:39:47Z
@MoonlightSentinel created dlang/druntime pull request #3594 "purge changelog" fixing this issue:
- Fix 22300 - Use reinterpreting cast for shared types during CTFE
Using the same method for compile- and runtime was enabled by
dlang/dmd#13203. Using a reinterpreting cast avoids any potentially
calling into user-defined `opCast` methods which might reject the cast.
https://github.com/dlang/druntime/pull/3594
Comment #4 by dlang-bot — 2021-10-20T09:18:45Z
dlang/druntime pull request #3594 "Fix 22300 - Use reinterpreting cast for shared types during CTFE" was merged into stable:
- 54cc0705b6d412874087f79ba8e1c54042280397 by MoonlightSentinel:
Fix 22300 - Use reinterpreting cast for shared types during CTFE
Using the same method for compile- and runtime was enabled by
dlang/dmd#13203. Using a reinterpreting cast avoids any potentially
calling into user-defined `opCast` methods which might reject the cast.
https://github.com/dlang/druntime/pull/3594
Comment #5 by dlang-bot — 2021-10-21T21:39:26Z
dlang/dmd pull request #13209 "Merge stable into master" was merged into master:
- 7f9ce4504af4cf08569493c1756a70b3f2faaaf9 by MoonlightSentinel:
Issue 22300 - Allow shared <-> unshared reinterpreting casts during CTFE
CTFE evaluation is single threaded only, hence it's safe to discard the
`shared` qualifier in a reinterpreting cast.
This change allows `-checkaction=context` to use a reinterpreting cast
for compile and runtime - which removes the problematic workaround
that caused the regression.
https://github.com/dlang/dmd/pull/13209
Comment #6 by dlang-bot — 2021-11-08T15:54:14Z
dlang/druntime pull request #3615 "Merge `stable` in `mater`" was merged into master:
- e8121cc6aaccfe5359071d077495de0c989be24c by MoonlightSentinel:
Fix 22300 - Use reinterpreting cast for shared types during CTFE
Using the same method for compile- and runtime was enabled by
dlang/dmd#13203. Using a reinterpreting cast avoids any potentially
calling into user-defined `opCast` methods which might reject the cast.
https://github.com/dlang/druntime/pull/3615