www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7871] New: RangeViolation with findSplitBefore

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

           Summary: RangeViolation with findSplitBefore
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
This code works with 2.058

import std.algorithm;

void main()
{
    enum lineStart = `<bookmark href="https://`;
    string line = `<bookmark href="https://stuff">`;
    auto a = findSplitBefore(line[lineStart.length .. $], `"`)[0];
}


But with the latest head, it gives

core.exception.RangeError q(7): Range violation
----------------
./q(_d_array_bounds+0x2a) [0x43aae6]
./q() [0x4389be]
./q(_Dmain+0x39) [0x4319c9]
./q(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x43b2ab]
./q(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void
delegate())+0x23) [0x43ac2b]
./q(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x3d) [0x43b2f9]
./q(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void
delegate())+0x23) [0x43ac2b]
./q(main+0xd3) [0x43abc3]
/lib/libc.so.6(__libc_start_main+0xf5) [0x7f907bdb9455]


I'm not sure what's causing the range violation though, since it goes away in
weird ways. If you remove the [0], it works, but if I add this line after it

auto b = a[0];

it works too. If I don't slice line anymore, it also works. If I slice line
like line[0 .. $] or line[$ .. $], it also works, but anything which slices
only part of the string (instead of none of it or all of it) results in it
failing. So, I have absolutely no clue what's going on here, but clearly
something is wrong with the code being generated.

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




Reduced test case:
----
struct Tuple
{
    string field;
    alias field this;
}

auto findSplitBefore(string haystack)
{
    return Tuple(haystack);
}

void main()
{
    string line = `<bookmark href="https://stuff">`;
    auto a = findSplitBefore(line[0 .. $])[0];
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code



This issue is caused by fixing bug 7583.

https://github.com/D-Programming-Language/dmd/pull/871

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




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/88bf66c5a61c85e46a862149c519d13f6b68a194
fix Issue 7871 - RangeViolation with findSplitBefore

This is a regression caused by fixing issue 7583.
When you syntaxCopy() a ast sub-tree, contained lengthVar is discarded.
But it is already inserted to scope symbol table. So we should share lengthVar
between all copy of syntax trees instead of creating new one.

https://github.com/D-Programming-Language/dmd/commit/6888809e505e3fed42089a35153702854918009d


Issue 7871 - RangeViolation with findSplitBefore

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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