www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3029] New: Bug in array value mangling rule

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

           Summary: Bug in array value mangling rule
           Product: D
           Version: 2.030
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec, wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: rsinfu gmail.com


This valid code:
--------------------
module test;
import std.stdio;
struct S(alias init)
{
    int[] content = init;
}
void main()
{
    S!([12, 3]) s1;
    S!([1, 23]) s2;
    writeln(s1.content);
    writeln(s2.content);
}
--------------------
prints wrong values:
--------------------
12 3
12 3
--------------------
The second line should be "1 23", not "12 3".

That is caused by a bug in the current array value mangling rule:
--------------------
Value:
    A Number Value...
--------------------
Under this rule, both S!([12, 3]) and S!([1, 23]) get mangled to the same name
"S4test15__T1SVG2iA2123Z". (Name collision!!!)

There should be delimiters in Values. For example:
--------------------
Value:
    A Number Values

Values:
    Value
    Value _ Values
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3029






---
Struct literals and associative array literals have the same bug too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3029






---
Another (possibly better) option is to fix the numeric literal mangling rule as
this:
--------------------
Value:
    i Number        // positive numeric literal
    i N Number      // negative numeric literal
--------------------
The prefix 'i' avoids the mangled-name collision. And this rule is consistent
with other literal mangling rules, which are prefixed by some character (e.g.
'e' for floating point literals).

Patch (expression.c):
--------------------
 void IntegerExp::toMangleBuffer(OutBuffer *buf)
 {
     if ((sinteger_t)value < 0)
-    buf->printf("N%jd", -value);
+    buf->printf("iN%jd", -value);
     else
-    buf->printf("%jd", value);
+    buf->printf("i%jd", value);
 }
--------------------

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



19:27:30 PST ---
changeset 370

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


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com



---
Why keep the backwards compatibility in D2?

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





 Why keep the backwards compatibility in D2?
Yes. With things like the recent change to ModuleInfo, you can't even update the compiler one revision without recompiling. So I don't think we have to worry about D2 backwards compatibility for the next month (which is why it's crucial to get these types of bugs fixed now). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3029


Kosmonaut <Kosmonaut tempinbox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Kosmonaut tempinbox.com



---

 changeset 370
http://www.dsource.org/projects/dmd/changeset/370 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3029


Walter Bright <bugzilla digitalmars.com> changed:

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



22:19:22 PST ---
Fixed dmd 1.057 and 2.041

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



What happened here?  Are we really maintaining backwards compatibility in only
the cases that _weren't_ buggy?  What legacy compiled code base is this
supposed to be supporting?

I seriously doubt anyone expects to be able to use a new version of dmd without
recompiling their code at this point.

See expression.c:2128

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