www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7339] New: [2.058] std.string.indexOf doesn't instantiate with inlining

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

           Summary: [2.058] std.string.indexOf doesn't instantiate with
                    inlining
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com
        Depends on: 4724



This is related to Bug 4724, but I'm filing it as a separate issue and labeling
it a regression because something (probably the more aggressive inlining that
was added for 2.058) expands the effects of that bug in ways that break
previously working code.  If we can't fix the compiler bug then we need to work
around it to avoid an awful regression.

import std.string;

void main() {
    "".indexOf("");
}

dmd -O -inline -release -c test.d
/home/dsimcha/dmd2/linux/bin64/../../src/phobos/std/algorithm.d(2970): Error:
function
std.string.indexOf!(char,char).indexOf.simpleMindedFind!(__lambda6,const(char)[],const(char)[]).simpleMindedFind
is a nested function and cannot be accessed from main

Here's a reduced version that doesn't import any Phobos modules:

void main() {
    "".indexOf("") ;
}

void indexOf(const(char)[] s, const(char)[] sub) {
    find!((dchar a, dchar b){return a == b;})
        (s, sub);
}

void find(alias pred)(const(char)[] haystack, const(char)[] needle) {
     pred(haystack[0], needle[0]);
}

$ dmd -c -O -inline -release test.d
test.d(11): Error: function test.indexOf.find!(delegate pure nothrow  safe
bool(dchar a, dchar b)
{
return cast(uint)a == cast(uint)b;
}
).find is a nested function and cannot be accessed from main

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7339


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 7199 ***

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