Bug 8893 – [ICE][CTFE] (interpret.c, line 3598) with failed array access

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-25T09:58:00Z
Last change time
2015-06-09T05:11:51Z
Keywords
CTFE, ice, pull
Assigned to
clugdbug
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-10-25T09:58:42Z
struct Foo { char[3] data; } int bar(Foo f) { return f.data[0]; } void main() { enum f = Foo(['A', 'B']); enum int b = bar(f); } DMD 2.061alpha: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char Assertion failure: '0' on line 3598 in file 'interpret.c'
Comment #1 by yebblies — 2012-10-30T01:26:03Z
Comment #2 by github-bugzilla — 2012-10-30T01:26:29Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f8015992623223985419fa1b69b5102feb6d462c Fix issue 8893 ICE(interpret.c) with invalid struct literal The implicit conversion can fail. In this case the struct literal is invalid (which means it will never reach CTFE).
Comment #3 by yebblies — 2012-10-30T01:29:20Z
I can't reproduce this on D1.
Comment #4 by bearophile_hugs — 2012-10-30T06:01:42Z
struct Foo { char[3] data; } int bar(Foo f) { return f.data[0]; } void main() { enum f = Foo(['A', 'B']); enum int b = bar(f); } The error message seems not correct: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char Instead of: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char[3]
Comment #5 by bearophile_hugs — 2012-10-30T10:58:55Z
(In reply to comment #4) > The error message seems not correct: Moved to Issue 8918
Comment #6 by bugzilla — 2013-04-19T00:05:27Z
Comment #7 by github-bugzilla — 2013-04-19T00:05:52Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ee45003465de6eef3165a7d94d06b3ac2127960e Fix issue 8893 ICE(interpret.c) with invalid struct literal The implicit conversion can fail. In this case the struct literal is invalid (which means it will never reach CTFE).