Thread overview
[Issue 15002] ICE interpret.c:331: virtual void CompiledCtfeFunction::onExpression(Expression*)::VarWalker::visit(ErrorExp*): Assertion `0' failed.
Sep 02, 2015
Vladimir Panteleev
Sep 02, 2015
Iain Buclaw
Sep 02, 2015
Vladimir Panteleev
[Issue 15002] [REG2.064] ICE interpret.c:331: virtual void CompiledCtfeFunction::onExpression(Expression*)::VarWalker::visit(ErrorExp*): Assertion `0' failed.
Sep 02, 2015
Vladimir Panteleev
Sep 02, 2015
Iain Buclaw
[Issue 15002] [REG2.064] ICE with invalid static variable initializer while CTFE
Sep 02, 2015
Kenji Hara
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |thecybershadow@gmail.com
           Severity|normal                      |regression

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
This seems to be a regression.

Introduced in https://github.com/D-Programming-Language/dmd/pull/2129

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Vladimir Panteleev from comment #1)
> This seems to be a regression.
> 
> Introduced in https://github.com/D-Programming-Language/dmd/pull/2129

Regression?  Regression from what?  Wrong-code to ICE?  Valid to ICE?  ICE to another ICE?

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Iain Buclaw from comment #2)
> Regression?  Regression from what?  Wrong-code to ICE?  Valid to ICE?  ICE to another ICE?

>From expected error message, to expected error message + ICE:

C:\Temp\D\issues\15002> dver 2.063 dmd -o- test.d
test.d(11): Error: array index 5 is out of bounds g_3[0 .. 3]
test.d(11): Error: cannot use non-constant CTFE pointer in an initializer
'&(__error)[0u]'

C:\Temp\D\issues\15002> dver 2.064 dmd -o- test.d
(auto-correcting D version 2.064 to 2.064.2)
test.d(11): Error: array index 5 is out of bounds g_3[0 .. 3]
test.d(11): Error: array index 5 is out of bounds g_3[0 .. 3]
CTFE: ErrorExp in test.d(11)
Assertion failure: '0' on line 310 in file 'interpret.c'

abnormal program termination

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE interpret.c:331:        |[REG2.064] ICE
                   |virtual void                |interpret.c:331: virtual
                   |CompiledCtfeFunction::onExp |void
                   |ression(Expression*)::VarWa |CompiledCtfeFunction::onExp
                   |lker::visit(ErrorExp*):     |ression(Expression*)::VarWa
                   |Assertion `0' failed.       |lker::visit(ErrorExp*):
                   |                            |Assertion `0' failed.

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

--- Comment #4 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Vladimir Panteleev from comment #3)
> (In reply to Iain Buclaw from comment #2)
> > Regression?  Regression from what?  Wrong-code to ICE?  Valid to ICE?  ICE to another ICE?
> 
> From expected error message, to expected error message + ICE:
> 

It looks like CTFE still tries to have a go at interpreting the invalid code. All that change does is enforce that the front-end never passes to CTFE an invalid state, so don't shoot the messenger!


Something like the following stops the invalid code from reaching CTFE:

diff --git a/src/init.d b/src/init.d
index dd9db91..1e53e22 100644
--- a/src/init.d
+++ b/src/init.d
@@ -822,15 +822,15 @@ public:
     Initializer semantic(Scope* sc, Type t, NeedInterpret needInterpret)
     {
         //printf("ExpInitializer::semantic(%s), type = %s\n", exp->toChars(),
t->toChars());
+        uint olderrors = global.errors;
         if (needInterpret)
             sc = sc.startCTFE();
         exp = exp.semantic(sc);
         exp = resolveProperties(sc, exp);
         if (needInterpret)
             sc = sc.endCTFE();
-        if (exp.op == TOKerror)
+        if (exp.op == TOKerror || olderrors != global.errors)
             return new ErrorInitializer();
-        uint olderrors = global.errors;
         if (needInterpret)
         {
             // If the result will be implicitly cast, move the cast into CTFE



Though the semantic passes should *really* do more in propagating ErrorExp up rather than relying on checking 'global.errors' for checking for problems during compilation.

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
            Summary|[REG2.064] ICE              |[REG2.064] ICE with invalid
                   |interpret.c:331: virtual    |static variable initializer
                   |void                        |while CTFE
                   |CompiledCtfeFunction::onExp |
                   |ression(Expression*)::VarWa |
                   |lker::visit(ErrorExp*):     |
                   |Assertion `0' failed.       |

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/5026

--
September 03, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b5b8d55d74cef95b2e5a6cf24a93438c2ae20141 fix Issue 15002 - ICE with invalid static variable initializer while CTFE

Front-end optimizer should propagate ErrorExp in each steps.

https://github.com/D-Programming-Language/dmd/commit/a94bcb5ab7e714bd9673a4367d1bff01f4338fce Merge pull request #5026 from 9rnsr/fix15002

[REG2.064] Issue 15002 - ICE with invalid static variable initializer while CTFE

--
September 07, 2015
https://issues.dlang.org/show_bug.cgi?id=15002

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b5b8d55d74cef95b2e5a6cf24a93438c2ae20141 fix Issue 15002 - ICE with invalid static variable initializer while CTFE

https://github.com/D-Programming-Language/dmd/commit/a94bcb5ab7e714bd9673a4367d1bff01f4338fce Merge pull request #5026 from 9rnsr/fix15002

--