Bug 21997 – CTFE should allow function pointer casts with different attributes

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-06T16:53:45Z
Last change time
2021-06-07T00:36:14Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2021-06-06T16:53:45Z
The following works at runtime but is rejected during CTFE: int nonPureFunc(int i) { return 2 * i; } void main() { auto pureFunc = cast(int function(int) pure) &nonPureFunc; assert(pureFunc(2) == 4); }
Comment #1 by dlang-bot — 2021-06-06T16:59:00Z
@ljmf00 updated dlang/dmd pull request #12514 "ctfeexpr: support reinterpreting cast when switching safe/pure/nothrow in both directions" fixing this issue: - Fix 21997 - Support reinterpreting cast when switching attributes in... ... both directions Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/12514
Comment #2 by dlang-bot — 2021-06-07T00:36:14Z
dlang/dmd pull request #12514 "ctfeexpr: support reinterpreting cast when switching safe/pure/nothrow in both directions" was merged into master: - 3f12de092d15c18e077b5a15c413aede3e40f57b by Luís Ferreira: Fix 21997 - Support reinterpreting cast when switching attributes in... ... both directions Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/12514