Bug 5421 – Ref function pointers can only be made with auto

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2011-01-07T06:49:00Z
Last change time
2011-06-06T19:46:53Z
Assigned to
nobody
Creator
eatingstaples

Comments

Comment #0 by eatingstaples — 2011-01-07T06:49:31Z
Creating a function pointer to a ref function can only be done using auto, but by no explicit means. Also, aliasing a ref function pointer to another type can't be done.
Comment #1 by schveiguy — 2011-01-07T07:05:33Z
Example code showing the issue: int x; ref int foo() { return x; } void main() { auto func = &foo; pragma(msg, typeof(func).stringof); // outputs "int function() ref" //int function() ref func; // uncomment for error func() = 5; } Error when auto is not used: testreffuncptr.d(9): no identifier for declarator int function() testreffuncptr.d(9): semicolon expected, not 'ref' testreffuncptr.d(9): found 'ref' instead of statement
Comment #2 by yebblies — 2011-06-06T19:46:53Z
*** This issue has been marked as a duplicate of issue 2753 ***