[Issue 588] lazy argument and nested symbol support to std.demangle

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 23 14:59:00 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=588





------- Comment #2 from fvbommel at wxs.nl  2006-11-23 16:58 -------
I was recently working on nested symbol support for std.demangle as well, and
ran into a bug. Your version has that same bug:
    urxae at ubuntu:~/tmp$ cat test.d
    int intfunc() {
        void inner() {
        }
        return 0;
    }

    class UDT {}

    UDT udtfunc() {
        void inner () {
        }
        return new UDT;
    }
    urxae at ubuntu:~/tmp$ dmd -c test.d
    urxae at ubuntu:~/tmp$ nm test.o | grep inner
    00000000 T _D4test7intfuncFZi5innerFZv
    00000000 T _D4test7udtfuncFZC4test3UDT5innerFZv
    urxae at ubuntu:~/tmp$ nm test.o | grep inner | ./demangle
    00000000 T int test.intfunc() . void inner()
    00000000 T class test.UDT.inner test.udtfunc() . void function()
(same effect for struct UDT & typedef UDT, IIRC)

It's caused by an ambiguity in the mangling. It is caused by several factors:
* Functions have their name first, and their return type last.
* UDTs (structs, classes and typedefs) have a mangled name of multiple parts
with no terminator.
* Inner functions are mangled as <mangled outer function> ~ <inner function>
* Inner function names (which comes directly after the mangled outer function)
have the same syntax as one part of an UDT name.

All of this causes the name of the inner function to be mistaken for the last
part of the return type.

The easiest fix would be for the mangling to change :). A simple terminator
char after an UDT name would do it.


-- 




More information about the Digitalmars-d-bugs mailing list