Jump to page: 1 2
Thread overview
[Issue 7810] New: ctRegex!`a|b` asserts at regex.d:1150
Apr 02, 2012
simendsjo
Apr 17, 2012
Dmitry Olshansky
Apr 17, 2012
Dmitry Olshansky
Apr 19, 2012
Dmitry Olshansky
May 18, 2012
Brad Anderson
May 18, 2012
Dmitry Olshansky
[Issue 7810] [CTFE] Typesafe variadic function with array of structs
Sep 26, 2012
Dmitry Olshansky
Sep 28, 2012
Don
Sep 28, 2012
Dmitry Olshansky
Oct 01, 2012
Don
Oct 01, 2012
Don
Oct 16, 2012
yebblies
Oct 17, 2012
Walter Bright
Nov 30, 2012
Dmitry Olshansky
Dec 12, 2012
Don
April 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810

           Summary: ctRegex!`a|b` asserts at regex.d:1150
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: simendsjo@gmail.com


--- Comment #0 from simendsjo <simendsjo@gmail.com> 2012-04-02 06:12:47 PDT ---
Using dmd 2.059 trunk

import std.regex;
//enum re = ctRegex!`(^[a-z]+)|([A-Z0-9][a-z0-9]+)|([A-Z]+)|([a-z]+)`;
//enum re = ctRegex!`(a)|(b)`;
enum re = ctRegex!`a|b`;
void main() {}


/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(876):        called
from here: this.parseRegex()
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6428):
called from here: parser.this(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6412):
called from here: regexImpl(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6437):
called from here: regex("a|b",[])
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(876):        called
from here: this.parseRegex()
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6428):
called from here: parser.this(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6412):
called from here: regexImpl(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6439):
called from here: regex("a|b",[])
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6439):
called from here: ctGenRegExCode(regex("a|b",[]))
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(876):        called
from here: this.parseRegex()
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6428):
called from here: parser.this(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6412):
called from here: regexImpl(pattern,flags)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6446):
called from here: regex("a|b",[])
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6446):
called from here:
StaticRegex(null,Regex(null,null,null,0u,0u,0u,0u,0u,null,null,ShiftOr(null,0u,0u))).this(regex("a|b",[]),&
func)
/home/simendsjo/code/dmd-trunk/build/src/phobos/std/regex.d(6463): Error:
template instance std.regex.ctRegexImpl!("a|b",[]) error instantiating
re.d(4):        instantiated from here: ctRegex!("a|b")
re.d(4): Error: template instance std.regex.ctRegex!("a|b") error instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810



--- Comment #1 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-04-17 01:55:53 PDT ---
Created an attachment (id=1094)
Stripped down regex parser

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh@gmail.com
          Component|Phobos                      |DMD


--- Comment #2 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-04-17 01:57:52 PDT ---
It's a bug in CTFE not in Phobos. R-T version runs the same code and doesn't hit the assert. See reduced test case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |beatgammit@gmail.com


--- Comment #3 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-04-19 09:36:11 PDT ---
*** Issue 7567 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810


Brad Anderson <eco@gnuk.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eco@gnuk.net


--- Comment #4 from Brad Anderson <eco@gnuk.net> 2012-05-17 19:40:52 PDT ---
Doesn't appear to require ctRegex to trigger.  This produces the same assertion failure.

import std.regex;

auto r = regex(r"(a|c");

void main() { }

This worked in 2.058 but not 2.059.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810



--- Comment #5 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-05-17 23:01:09 PDT ---
(In reply to comment #4)
> Doesn't appear to require ctRegex to trigger.  This produces the same assertion failure.
> 
> import std.regex;
> 
> auto r = regex(r"(a|c");
> 
> void main() { }
> 
> This worked in 2.058 but not 2.059.

not the same.

And yes, global variable == CTFE parser.

+ r"(a|c" unbalanced paren, so it should eventually throw exception but it asserts before it have the chance to do that.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ctRegex!`a|b` asserts at    |[CTFE] Typesafe variadic
                   |regex.d:1150                |function with array of
                   |                            |structs


--- Comment #6 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-09-26 11:47:45 PDT ---
I've finally pinned down this bugger. The problem is in typesafe variadic function if the parameter type is a struct.

See simple test below:
//encoded IR instruction
struct Bytecode
{
    uint raw;
}

int fn1(T)(T[] items...)
{
    assert(items[0] == 20);
    return 42;
}

int fn2(T)(T[] items...)
{
    assert(items[0] == Bytecode(20));
    return 42;
}

//this passes...
static assert(fn1(20, 30) == 42);

//this dies inside of fn2
static assert(fn2(Bytecode(20), Bytecode(30)) == 42);

void main()
{//both of these pass at R-T
    assert(fn1(20, 30) == 42);
    assert(fn2(Bytecode(20), Bytecode(30)) == 42);
}

Output:

sr_micro.d(15): Error: assert(items[0u] == Bytecode(20u)) failed
sr_micro.d(23):        called from here: fn2((Bytecode[2u] __arrayArg6 = void;
 , __arrayArg6[0u] = Bytecode(20u) , __arrayArg6[1u] = Bytecode(30u) ,
cast(Bytecode[])__arrayArg6))
sr_micro.d(23):        while evaluating: static assert(fn2((Bytecode[2u]
__arrayArg6 = void;
 , __arrayArg6[0u] = Bytecode(20u) , __arrayArg6[1u] = Bytecode(30u) ,
cast(Bytecode[])__arrayArg6)) == 42)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810



--- Comment #7 from Don <clugdbug@yahoo.com.au> 2012-09-28 00:01:52 PDT ---
Problem happens when an array is initialized to void in global scope (outside of CTFE) and then modified in CTFE. Haven't fixed this yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810



--- Comment #8 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-09-28 03:08:46 PDT ---
(In reply to comment #7)
> Problem happens when an array is initialized to void in global scope (outside of CTFE) and then modified in CTFE. Haven't fixed this yet.

Thanks for looking into it. It took soo long to reduce but at least now I have an idea of a workaround.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7810



--- Comment #9 from Don <clugdbug@yahoo.com.au> 2012-10-01 06:17:47 PDT ---
Further reduced shows it's a problem with void initialized static arrays. I have a fix.

int bug7810() {

    int[1][3] x = void;
    x[0] = [2];
    x[1] = [7];
    assert(x[0][0] == 2);
    return 1;
}
static assert(bug7810());

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2