Bug 10317 – (2.063): Recursive error within Phobos

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-09T07:21:00Z
Last change time
2017-07-02T16:24:27Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-06-09T07:21:42Z
----- module test; import std.algorithm; struct Set(E) { E[] sortedElements() inout { E[] elems = payload.keys; sort(elems); // Causes error return elems; } int[E] payload; } enum E { a, b } struct S { Set!E e; } void main() { S s; } ----- 2.062: $ dmd test.d 2.063 $ dmd test.d C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\format.d(2009): Error: template instance std.traits.CharTypeOf!(E) recursive expansion
Comment #1 by andrej.mitrovich — 2013-06-09T17:31:33Z
Btw, when building with MSC the error never shows up, the compiler just spins the CPU forever. I guess this is a bug of its own.
Comment #2 by andrei — 2013-06-09T18:18:15Z
Simplified: import std.algorithm; enum E { a, b } void main() { auto a = new E[100]; sort(a); }
Comment #3 by andrei — 2013-06-09T19:08:51Z
I looked into this, here's how far I got: On https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L8130, "static if (is(typeof(text(r))))" is evaluated. That's what's causing the crash. The question is what's causing the bug. I don't know; instantiating typeof(text(r)) works properly in tests.
Comment #4 by andrej.mitrovich — 2013-06-09T19:12:35Z
(In reply to comment #3) > I looked into this, here's how far I got: > > On > https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L8130, > "static if (is(typeof(text(r))))" is evaluated. That's what's causing the > crash. The question is what's causing the bug. I don't know; instantiating > typeof(text(r)) works properly in tests. What I'm wondering: when does text(r) ever not work? Is there an actual test-case for this?
Comment #5 by andrei — 2013-06-09T19:14:03Z
(In reply to comment #4) > (In reply to comment #3) > > I looked into this, here's how far I got: > > > > On > > https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L8130, > > "static if (is(typeof(text(r))))" is evaluated. That's what's causing the > > crash. The question is what's causing the bug. I don't know; instantiating > > typeof(text(r)) works properly in tests. > > What I'm wondering: when does text(r) ever not work? Is there an actual > test-case for this? Hmm, good point. I don't know. I think at this time we have a textual representation for everything.
Comment #6 by andrej.mitrovich — 2013-06-09T19:43:52Z
(In reply to comment #5) > Hmm, good point. I don't know. I think at this time we have a textual > representation for everything. Ok, I'll whip up a quick test and a phobos pull, so we can at least avoid blocking the .2 release.
Comment #7 by andrej.mitrovich — 2013-06-09T19:47:10Z
(In reply to comment #6) > (In reply to comment #5) > > Hmm, good point. I don't know. I think at this time we have a textual > > representation for everything. > > Ok, I'll whip up a quick test and a phobos pull, so we can at least avoid > blocking the .2 release. https://github.com/D-Programming-Language/phobos/pull/1343
Comment #8 by github-bugzilla — 2013-06-10T09:41:21Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8f5f220194c313dad1cdc36db797ecbee78844d0 Fix Issue 10317 - Remove text(range) check and avoid recursive instantiation bug. https://github.com/D-Programming-Language/phobos/commit/28189ff131e9003d1b0ed5a148f43d65f1823c87 Merge pull request #1343 from AndrejMitrovic/Fix10317 Issue 10317 - Remove text(range) check and avoid recursive instantiation bug.
Comment #9 by andrej.mitrovich — 2013-06-10T11:35:58Z
The library fix is in place, but we still have to figure out why 2.062 doesn't exhibit the same behavior even though it has the same library code. So I'm downgrading this to a normal bug to avoid blocking the .2 release
Comment #10 by dlang-bugzilla — 2017-07-02T16:24:27Z
(In reply to Andrej Mitrovic from comment #9) > The library fix is in place, but we still have to figure out why 2.062 > doesn't exhibit the same behavior even though it has the same library code. > So I'm downgrading this to a normal bug to avoid blocking the .2 release As no reproducible test case has materialized in the past 4 years, closing. FWIW, this regression was initially introduced in https://github.com/dlang/dmd/pull/1760.