Bug 2368 – Calling a function with an address of another function, then calling a returned object is rejected

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-09-21T19:07:00Z
Last change time
2015-06-09T01:20:16Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
snake.scaly

Comments

Comment #0 by snake.scaly — 2008-09-21T19:07:45Z
Sorry for the long summary. In the following code, the last line of main() is rejected by the compiler: int function() wrap(void function()) { static int worker() { return 0; } return &worker; } void main() { auto x = wrap(&main)(); // OK wrap(&main)(); // found '&' when expecting ')'; no identifier for declarator wrap; etc. } This seems to have to do something with an ampersand ('&') because similar code with passing other objects works: auto m = &main; wrap(m)(); compiles correctly.
Comment #1 by bugzilla — 2008-10-20T22:18:49Z
Fixed dmd 1.036 and 2.020