www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4494] New: [ICE] Array literal filled with results of void function

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

           Summary: [ICE] Array literal filled with results of void
                    function
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-07-23 09:59:30 PDT ---
void foo() {}
void main() {
    [foo];
}


Dmd 2.047 prints:
Internal error: ..\ztc\cod1.c 2650

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


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com
         OS/Version|Windows                     |All


--- Comment #1 from Iain Buclaw <ibuclaw ubuntu.com> 2011-01-01 11:21:49 PST ---
Changing platform to All (affects Linux too).

Similar code:

void[] p = [cast(void)42];

As of DMD-2.051, now prints:
Internal error: ../ztc/cod1.c 3057

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


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Iain Buclaw <ibuclaw ubuntu.com> 2011-04-11 14:39:36 PDT ---
diff --git a/src/expression.c b/src/expression.c
index 9d116b9..1bd9e42 100644
--- a/src/expression.c
+++ b/src/expression.c
   -3200,6 +3200,10    Expression *ArrayLiteralExp::semantic(Scope *sc)
     type = t0->arrayOf();
     //type = new TypeSArray(t0, new IntegerExp(elements->dim));
     type = type->semantic(loc, sc);
+
+    if (type->nextOf()->ty == Tvoid)
+        error("array literal of type void[] has no value");
+
     return this;
 }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4494



--- Comment #3 from Iain Buclaw <ibuclaw ubuntu.com> 2011-04-11 14:44:50 PDT ---
Maybe

  if (type->nextOf()->ty == Tvoid)
      error("%s of type void[] has no value", toChars());


Is a better error message (I really am no good at writing them :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4494



--- Comment #4 from Iain Buclaw <ibuclaw ubuntu.com> 2011-04-14 04:36:55 PDT ---
Oops, previous patch didn't take into account that empty '[]' array literals
are allowed to be void.

diff --git a/src/expression.c b/src/expression.c
index 9d116b9..1e68ce7 100644
--- a/src/expression.c
+++ b/src/expression.c
   -3197,6 +3197,9    Expression *ArrayLiteralExp::semantic(Scope *sc)
     Type *t0;
     elements = arrayExpressionToCommonType(sc, elements, &t0);

+    if (elements->dim > 0 && t0->ty == Tvoid)
+        error("array literal %s has no value", toChars());
+
     type = t0->arrayOf();
     //type = new TypeSArray(t0, new IntegerExp(elements->dim));
     type = type->semantic(loc, sc);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4494


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pszturmaj tlen.pl


--- Comment #5 from kennytm gmail.com 2011-05-05 11:45:10 PDT ---
*** Issue 5929 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 05 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4494


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2011-06-29
00:57:54 PDT ---
https://github.com/D-Programming-Language/dmd/commit/dbdbeb1ed9890e317c0fbb594dd331f18d025864

https://github.com/D-Programming-Language/dmd/commit/d7096004298cdbffa4f4889be47d8f6ee627fdfc

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