[Issue 11540] New: [ICE] Unknown segfault during CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 18 07:49:31 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11540

           Summary: [ICE] Unknown segfault during CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-11-18 07:49:27 PST ---
Credit goes to Vladimir and his dustmite tool.

The following is auto-reduced test case:

enum IR:uint 
{
Trie  
}

struct Bytecode
{
uint raw;
@property data() { return raw ; }

@property code() { return cast()raw>>24; }

}

template BasicElementOf(Range)
{
alias typeof(Range.init) BasicElementOf;
}

struct Parser(R)
{
Bytecode[] ir;       
CodepointSet[] charsets;  
this(S)(R , S )
{
try
        parseRegex;
catch(Exception e)
error(e.msg);
}

void put(Bytecode code)
{
ir ~= code;
}

@trusted parseRegex()
{
parseAtom;
}

void parseAtom()
{
parseEscape;
}

@trusted charsetToIr(CodepointSet set)
{
put(Bytecode());
charsets ~= set;
}

@trusted parseEscape()
{

charsetToIr(unicode.Nd);
}

@trusted error(string )
{
}

alias BasicElementOf!R Char;
Regex!Char program()
{
return Regex!Char(this);
}
}


struct Regex(Char)
{
CodepointSet[] charsets; 
Bytecode[] ir;      

@trusted lightPostprocess()
{
Kickstart!Char(this, new uint[](256));
}

this(S)(Parser!(S) p)
{
ir = p.ir;
charsets = p.charsets;
lightPostprocess;
}
}

struct ShiftOr(Char)
{
struct ShiftThread
    {
uint pc;
}

this(Regex!Char re, uint[] )
{
ShiftThread t = ShiftThread();
switch(re.ir[t.pc].code)
{
case IR.Trie:
                    auto set = re.charsets[re.ir[t.pc].data];
goto L_OutOfLoop;
L_OutOfLoop:
                            ;
}
}

}

alias ShiftOr Kickstart;

auto regex(S)(S pattern, const(char)[] flags="")
{
regexImpl(pattern);
}

auto regexImpl(S)(S pattern, const(char)[] flags="")
{
auto parser = Parser!(typeof(pattern))(pattern, flags);
parser.program;
}


template ctRegexImpl(alias pattern, string flags=[])
{
enum r = regex(pattern);
}

template ctRegex(alias pattern, alias flags=[])
{
enum ctRegex = ctRegexImpl!pattern;
}

struct GcPolicy
{
}


alias InversionList!GcPolicy CodepointSet;

struct InversionList(SP=GcPolicy)
{
alias size_t Marker;

Marker addInterval()
in
    {
}
body
    {
}

Uint24Array!SP data;
}struct Uint24Array(SP=GcPolicy)
{
~this()
{
}

}

struct unicode
{
static opDispatch(string name)()
{
return loadAny(name);
}

static loadAny(Set=CodepointSet, C)(C)
{
Set set;
return set;
}

}

void foo()
{
ctRegex!`(?P<Quot>\d+)`;
}

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


More information about the Digitalmars-d-bugs mailing list