www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 142] New: Assertion failure: '0' on line 610 in file 'template.c'

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

           Summary: Assertion failure: '0' on line 610 in file 'template.c'
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lio lunesu.com


// I don't know if the code is supposed to work,
// but I'm trying to convert
// #define A(x) x=2
template A(alias T) {
        void A(T) { T=2; }
}

void main()
{
        int i;
        A(i);
        assert(i==2);
}


-- 
May 17 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=142





------- Comment #1 from fvbommel wxs.nl  2006-05-17 16:38 -------
That definitely looks like a compiler bug.

That said, I'm pretty sure that code shouldn't compile anyway.
I think what you're trying to do is probably something like this:

// translation of "#define A(x) x=2".
// Note it can't be translated exactly because the macro doesn't
// have parentheses around it, so code like "A(x) + 2" _will_ do
// something different.
// (i.e. this is actually the translation of "#define A(x) (x=2)")
template A(T) {
        void A(out T x) { x=2; }
}

void main()
{
        int i;
        A(i);
        assert(i==2);
}


-- 
May 17 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=142


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |ice-on-invalid-code




------- Comment #2 from smjg iname.com  2006-05-18 07:54 -------
(In reply to comment #1)
 That definitely looks like a compiler bug.

An assertion failure is a bug by definition.
 That said, I'm pretty sure that code shouldn't compile anyway.

It took me a moment to work it out. But indeed, it shouldn't compile, because the parameter T has no type. --
May 18 2006
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-05-17:
 // I don't know if the code is supposed to work,
 // but I'm trying to convert
 // #define A(x) x=2
 template A(alias T) {
         void A(T) { T=2; }
 }

 void main()
 {
         int i;
         A(i);
         assert(i==2);
 }

Added to DStress as http://dstress.kuehne.cn/nocompile/b/bug_template_610_A.d http://dstress.kuehne.cn/nocompile/b/bug_template_610_B.d http://dstress.kuehne.cn/run/b/bug_template_610_C.d http://dstress.kuehne.cn/nocompile/b/bug_template_610_D.d http://dstress.kuehne.cn/nocompile/b/bug_template_610_E.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEbcGt3w+/yD4P9tIRAltgAJ9eDNdj4UwVVLBBOS71y+P08DovOgCglJQ1 /bx90fnYGDBlXN+TlpuA+3s= =/kd+ -----END PGP SIGNATURE-----
May 19 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=142


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla digitalmars.com  2006-05-25 04:24 -------
Fixed 0.158


-- 
May 25 2006