www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2392] New: Parsing ambiguity between function pointer declaration and function call

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392

           Summary: Parsing ambiguity between function pointer declaration
                    and function call
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: bugzilla digitalmars.com


The following code won't compile:

int function() foo(int i);
int* p;
void main() {
  foo(*p)();
}

because foo(*p)() looks like a C-style declaration of p being a pointer to a
function that returns type foo. Too work around, add parentheses:

   (foo(*p)());

I can't see any way to fix this without dispensing with C style function
pointer declarations.


-- 
Oct 04 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392





------- Comment #1 from tomas famolsen.dk  2008-10-04 17:41 -------
 I can't see any way to fix this without dispensing with C style function
pointer declarations.

Seems very reasonable to remove these to me --
Oct 04 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392





------- Comment #2 from terranium yandex.ru  2008-10-09 06:17 -------
(In reply to comment #0)
 C-style declaration of p being a pointer to a
 function that returns type foo.

foo doesn't look like type to me, it's rather a forward declaration of a function. So compiler just needs to distinguish functions from types. --
Oct 09 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com




------- Comment #3 from smjg iname.com  2008-11-24 10:17 -------
That would be a dependency of parsing on semantic analysis, which is something
D by design doesn't have.

I agree that C-style function pointer declarations should be thrown out, just
as C-style cast syntax has been already.


-- 
Nov 24 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392


Ellery Newcomer <ellery-newcomer utulsa.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brix brix-verden.dk


--- Comment #4 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2010-03-17
13:11:43 PDT ---
*** Issue 3980 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 17 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392



--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2010-11-09
19:46:40 PST ---
The disambiguation rule for "is it a declaration or a statement" is resolved by
the rule "if it looks like a declaration, it is a declaration". The behavior
you're seeing is as designed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2392


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2010-11-09
19:53:19 PST ---
http://www.dsource.org/projects/phobos/changeset/2149

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2010