Bug 7199 – std.string.indexof cannot be compiled with -inline

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-02T07:30:00Z
Last change time
2015-06-09T04:41:31Z
Keywords
rejects-valid
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2012-01-02T07:30:11Z
With the latest version from github, this code fails to compile with "-inline": module test; import std.string; int main() { string s = "abcd"; int index = indexOf(s, "b"); return index; } m:\s\d\rainers\phobos\std\algorithm.d(2970): Error: function std.string.indexOf! (char,char).indexOf.simpleMindedFind!(__lambda6,const(char)[],const(char)[]).sim pleMindedFind is a nested function and cannot be accessed from main This works with dmd 2.057 or without -inline.
Comment #1 by hoganmeier — 2012-01-20T04:59:43Z
I posted a reduced version to http://d.puremagic.com/issues/show_bug.cgi?id=4841#c2 cause I thought they were the same.
Comment #2 by clugdbug — 2012-01-24T12:34:40Z
*** Issue 7339 has been marked as a duplicate of this issue. ***
Comment #3 by clugdbug — 2012-01-24T12:38:12Z
I've changed this to a Phobos bug, since it's a regression caused by a change in Phobos. The root cause DMD bug 4841 is not a regression.
Comment #4 by webby — 2012-01-27T15:19:56Z
If i try to build Juno with the latest DMD/Phobos as of now, i get Error: function juno.locale.core.Culture.displayName cannot get frame pointer to simpleMindedFind (Where displayName calls std.string.indexOf). It builds ok without -inline.
Comment #5 by hoganmeier — 2012-01-27T15:55:48Z
Richard, yes, see my comment 1 for the reduced version.
Comment #6 by bugzilla — 2012-02-05T12:36:22Z
This is not a duplicate of bug 4841.
Comment #7 by bugzilla — 2012-02-05T12:38:07Z
Trass3r's example fails: R1 find(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) { return simpleMindedFind!pred(haystack, needle); } R1 simpleMindedFind(alias pred, R1, R2)(R1 haystack, R2 needle) { bool haystackTooShort() { return true; } return haystack; } sizediff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)sub) { const(Char1)[] balance = find!({})(s, sub); return -1; } string extStr; void main() { extStr.indexOf("bla"); }
Comment #8 by bugzilla — 2012-02-05T12:48:05Z
A simplified example: void find(alias pred)() { bool hay() { return true; } } void index() { find!({})(); } void main() { index(); }
Comment #9 by github-bugzilla — 2012-02-05T15:56:01Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9c38305a4d4a910b56c498ddece7c85ff7fb8f97 fix Issue 7199 - std.string.indexof cannot be compiled with -inline