www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4828] New: ICE w/ non-boolean dot expression sth.template_instance in static if

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4828

           Summary: ICE w/ non-boolean dot expression
                    sth.template_instance in static if
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice-on-invalid-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com



---
Using an syntax `something.template_instance` in static-if triggers an
assertion at expression.c(817).
--------------------
struct S
{
    template P() {}
    alias P!() p;
}
static if (S.p) {}  // ICE
--------------------
% dmd -o- -c test
Assertion failed: (pr != PREC_zero), function expToCBuffer, file expression.c,
line 817.
--------------------

Assertion failure did not occur before svn r629.
--------------------
% dmd-r628 -o- -c test
test.d(6): Error: expression S dotexp P!() is not constant or does not evaluate
to a bool
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4828




---
Created an attachment (id=748)
Patch against dmd r660, implements DotExp::toCBuffer()

The attached patch implements DotExp::toCBuffer().

The syntax `something.template_instance` yields a DotExp.  The repro code in

Then it calls toCBuffer() on the DotExp object, but it's not overridden, so the
base class' BinExp::toCBuffer() is invoked.

It hits the assertion because `precedence[TOKdotexp]` is PREC_zero:
--------------------
void BinExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
    expToCBuffer(buf, hgs, e1, precedence[op]); // op == TOKdotexp
...
--------------------

So, DotExp::toCBuffer() needs to be implemented to handle this case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4828


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



Another regression from the same svn commit, that hits the same assert:

static assert(!is(typeof(Object.tupleof[2000]=0)));
---
precedence not defined for token 'tuple'
assert expression.c(816) precedence[e->op] != PREC_zero

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 06 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4828


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



13:22:37 PDT ---
http://www.dsource.org/projects/dmd/changeset/669

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