www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3650] New: functions are considered pointers

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 26 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Stewart Gordon <smjg iname.com> changed:

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



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: -------
Dec 26 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3650


Stewart Gordon <smjg iname.com> changed:

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



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: -------
Jan 02 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3650




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: -------
Jan 02 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3650




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: -------
Jan 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 06 2011
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Apr 12 2011