www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2862] New: ICE: assert template.c(4048) global.errors

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

           Summary: ICE: assert template.c(4048) global.errors
           Product: D
           Version: 2.028
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: davidl 126.com


import std.stdio;
void bug(T...)(T t)
{
  writefln(T);
}

void main()
{
  bug(1,2);
}


-- 
Apr 20 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2862


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.028                       |1.00



An ancient bug. Reduced test case fails on D1 as well, as far back as 0.175.

void foo(T...)(T t) {}
void bug(T...)(T t){
   foo(T);
}

void main(){
  bug(1,2);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2862


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|ICE: assert                 |ICE(template.c) using type
                   |template.c(4048)            |tuple as function argument
                   |global.errors               |



Root cause: should not be able to use a type as a function parameter.
Currently, error messages are generated in the back-end, but some cases are
missed. This moves the error message to the front-end where it belongs.
---
Example of backend error now moved to front-end:
void foo(int x){}

alias int BAD;
void main(){
  foo(BAD);
}
---
And also note that non-type tuples are OK as function parameters. This test
case still passes.
int foo(T...)(T t) { return t[0]+t[1]; }
template bug(T...){
   int x = foo(T) + 4;
}

void main(){
  int z = bug!(1, 2).x;
  assert(z==7);
}
---



Index: expression.c
===================================================================
--- expression.c    (revision 215)
+++ expression.c    (working copy)
   -462,7 +462,10   

     for (size_t i = 0; i < exps->dim; i++)
     {   Expression *arg = (Expression *)exps->data[i];
-
+        if (arg->op == TOKtype)
+        {    arg->error("type %s is not an expression", arg->toChars());
+        arg = new IntegerExp(arg->loc, 0, Type::tint32);
+        }
         if (!arg->type)
         {

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2862




Aargh, this doesn't work because types ARE valid function arguments inside type
expressions. There does not seem to be better place to catch this error
(functionArguments is too late).
So a superficial patch is just to turn the ICE into an error message. It's not
obvious how to phrase the error message so that it makes sense though.

template.c line 4226.

        else
        {
+        if (ta->ty==Ttuple) {
+            ta->error(loc, "Type tuple %s is not a valid template argument",
ta->toChars());
+            continue;        
+        }

#ifdef DEBUG
        printf("ta = %d, %d, %s\n", ta->ty, Ttuple, ta->toChars());
#endif
        assert(global.errors);
        }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2862


Leandro Lucarella <llucax gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax gmail.com



PST ---
SVN commit: http://www.dsource.org/projects/dmd/changeset/233

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2862


Walter Bright <bugzilla digitalmars.com> changed:

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



11:30:02 PST ---
Fixed dmd 1.051 and 2.036

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