Thread overview
[Issue 3650] New: functions are considered pointers
Dec 26, 2009
nfxjfg@gmail.com
Dec 26, 2009
Stewart Gordon
Jan 03, 2010
Stewart Gordon
Jan 03, 2010
nfxjfg@gmail.com
Jan 19, 2010
nfxjfg@gmail.com
Jan 07, 2011
nfxjfg@gmail.com
Jan 07, 2011
Brad Roberts
Apr 12, 2011
Walter Bright
December 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3650

           Summary: functions are considered pointers
           Product: D
           Version: 1.051
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


--- Comment #0 from nfxjfg@gmail.com 2009-12-26 09:45:34 PST ---
First off, this bug report is for dmd 1.053, not 1.051; but bugzilla let's me only select up to 1.051.

The following code outputs "what (void())()", which shows that function
pointers are matched with is(T T2 : T2*). I think this shouldn't be the case:
although technically function pointers really are pointers, D doesn't declare
them using the pointer syntax, doesn't allow them to be dereferenced, and they
don't point to any type.

If this bug is fixed, functions won't match with is(T T2 : T2*) anymore.

If this is just an anti-feature and not a bug, please mark this bug report as "invalid".

struct X {
    void function() foo;
}

void moo(T)() {
    static if (is(T T2 : T2*)) {
        pragma(msg, "what "~T2.stringof);
    }
}

void main() {
    X x;
    foreach (int index, z; x.tupleof) {
        moo!(typeof(z));
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Stewart Gordon <smjg@iname.com> changed:

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


--- Comment #1 from Stewart Gordon <smjg@iname.com> 2009-12-26 11:11:08 PST ---
I've always been under the impression that immediate function types aren't meant to exist in D, which would mean that the is expression should fail.

But there does seem to be some confusion over it.  And in any case, the stringof does seem wrong.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.054                       |1.051


--- Comment #2 from Stewart Gordon <smjg@iname.com> 2010-01-02 16:44:03 PST ---
You stated that it's 1.053 you found it in, but inadvertently set it to 1.054 when the version list was updated.

But I've just found that I'm still on 1.051 and the bug shows in it, so reverting per policy.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3650



--- Comment #3 from nfxjfg@gmail.com 2010-01-02 16:51:16 PST ---
I guess the bug exists since the early days of dmd.
Just to clarify it: it also exists in 1.054. (That's why I changed it; sorry
for the confusion, won't do again.)

A statement from Walter whether this is an anti-feature or a bug would be nice. (And in general, there are far too many bug reports with unknown status, that remain uncommented.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3650



--- Comment #4 from nfxjfg@gmail.com 2010-01-19 12:30:59 PST ---
PS: as far as is() is concerned, functions should just work like delegates. Any difference should be considered as bug.

Also, if this happens not to be a bug, please mark it as "enhancement", and not as "invalid" (like I said above).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3650


nfxjfg@gmail.com changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |INVALID


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-04-12 11:15:01 PDT ---
void function() foo;

declares foo as a function pointer.

is(T T2 : T2*)

matches a pointer, and sets T2 to whatever is pointed to.

Hence what is printed out is correct. Not a bug.

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