www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5394] New: Changing the order of writing pragma(msg, (...).mangleof) changes the result

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

           Summary: Changing the order of writing pragma(msg,
                    (...).mangleof) changes the result
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: wfunction hotmail.com



I have this code below:

// Code =================================
private template Dummy(sth...) { struct Hook { } }
template myMangledName(sth...) if (sth.length == 1)
{
    enum string myMangledName = Dummy!(sth[0]).Hook.mangleof;
    pragma(msg, Dummy!().Hook.mangleof);
    pragma(msg, Dummy!(sth).Hook.mangleof);
}
class Temp
{
    int Field;
    pragma(msg, "IGNORE THIS... ", myMangledName!(Field));
}
// End Code =============================

When I compile it with DMD 2.051, I get this text printed:

IGNORE THIS... S4meta10__T5DummyZ4Hook
S4meta4Temp32__T5DummyS19_D4meta4Temp5FieldiZ4Hook
S4meta4Temp32__T5DummyS19_D4meta4Temp5FieldiZ4Hook


However, if I compile this:

// Code =================================
private template Dummy(sth...) { struct Hook { } }
template myMangledName(sth...) if (sth.length == 1)
{
    enum string myMangledName = Dummy!(sth[0]).Hook.mangleof;
    pragma(msg, Dummy!(sth).Hook.mangleof);
    pragma(msg, Dummy!().Hook.mangleof);
    //Notice that the above two are switched
}
class Temp
{
    int Field;
    pragma(msg, "IGNORE THIS... ", myMangledName!(Field));
}
// End Code =============================


I get this result:

IGNORE THIS... S4meta4Temp32__T5DummyS19_D4meta4Temp5FieldiZ4Hook
S4meta10__T5DummyZ4Hook
S4meta4Temp32__T5DummyS19_D4meta4Temp5FieldiZ4Hook


which is obviously different from the last one. Is this a bug?

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


Kenji Hara <k.hara.pg gmail.com> changed:

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



This is not a bug. Test with following code.

private template Dummy(sth...) { struct Hook { } }
template myMangledName(sth...) if (sth.length == 1)
{
    enum string myMangledName = Dummy!(sth[0]).Hook.mangleof;
    version(A)
    {
        pragma(msg, "1[", Dummy!().Hook.mangleof, "]");
        pragma(msg, "2[", Dummy!(sth).Hook.mangleof, "]");
    }
    version(B)
    {
        pragma(msg, "2[", Dummy!(sth).Hook.mangleof, "]");
        pragma(msg, "1[", Dummy!().Hook.mangleof, "]");
    }
}
class Temp
{
    int Field;
    pragma(msg, "IGNORE THIS... ", myMangledName!(Field));
}

output:

c:\d> dmd -version=A -run test.d
IGNORE THIS... 1[S4test10__T5DummyZ4Hook]
2[S4test4Temp32__T5DummyS19_D4test4Temp5FieldiZ4Hook]
S4test4Temp32__T5DummyS19_D4test4Temp5FieldiZ4Hook

c:\d> dmd -version=B -run test.d
IGNORE THIS... 2[S4test4Temp32__T5DummyS19_D4test4Temp5FieldiZ4Hook]
1[S4test10__T5DummyZ4Hook]
S4test4Temp32__T5DummyS19_D4test4Temp5FieldiZ4Hook

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5394




Sorry, could you please explain how/why you say that is not a bug? o.O

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5394





 Sorry, could you please explain how/why you say that is not a bug? o.O
See the output of my code. In both version(A) and version(B), pragma(msg, "1[", Dummy!().Hook.mangleof, "]"); prints "1[S4test10__T5DummyZ4Hook]", and pragma(msg, "2[", Dummy!(sth).Hook.mangleof, "]"); prints "2[S4test4Temp32__T5DummyS19_D4test4Temp5FieldiZ4Hook]". It isn't dependent to the order. There is no bug. And, with current dmd implementation, pragma(msg, e1, e2, ...); is interpreted as: eval e1 -> print e1 -> eval e2 -> print e2 -> ... So the printing of pragmas in myMangledName template runs *before* the printing of myMangledName!(Field) result. (I can agree it is compiler implementation dependent behavior, but cannot agree to mark it as a bug.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5394




Oh lol. What version of DMD are you on? Probably just got fixed lol, since they
didn't have the same output when I checked.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5394




I'm using 2.060head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 01 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5394




That's probably why lol. Thanks for posting.

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