[Issue 8563] Exception segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 18 09:06:38 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=8563


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-02-18 09:06:35 PST ---
Reduced 

struct DirEntry
{
    string name;
}

struct DirIteratorImpl
{
    DirEntry _cur;
    @property bool empty(){  return true; }
    @property DirEntry front(){ return _cur; }
    void popFront() { }
}

struct RefCounted
{
    struct RefCountedStore
    {
        private struct Impl
        {
            DirIteratorImpl _payload;
            size_t _count;
        }

        private Impl* _store;

    }
    RefCountedStore _refCounted;

    ~this()
    {
        if (_refCounted._store)
            _refCounted._store._count = 0;
    }

    ref inout(DirIteratorImpl) refCountedPayload() inout
    {
        if (_refCounted._store)
            return _refCounted._store._payload;
        else
            throw new Exception("absent");
    }
    alias refCountedPayload this;
}

struct DirIterator
{
    RefCounted impl;
    this(string pathname)
    {
        throw new Exception("");
    }
    @property bool empty(){ return impl.empty; }
    @property DirEntry front(){ return impl.front; }
    void popFront(){ impl.popFront(); }
}

auto dirEntries(string path)
{
    return DirIterator(path);
}

void main() {
      foreach(s; dirEntries("test")) {} 
}

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


More information about the Digitalmars-d-bugs mailing list