[Issue 2368] New: Calling a function with an address of another	function, then calling a returned object is rejected
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Sep 21 17:07:46 PDT 2008
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=2368
           Summary: Calling a function with an address of another function,
                    then calling a returned object is rejected
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: snake.scaly at gmail.com
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.
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list