← Back to index
|
Original Bugzilla link
Bug 6420 – [CTFE] ICE on dereference-assigning to a pointer casted from a literal
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-07-31T16:10:00Z
Last change time
2011-08-22T22:47:51Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
kennytm
Comments
Comment #0
by kennytm — 2011-07-31T16:10:10Z
Test case: -------------- static assert( { *cast(int*)45 = 1; return true; }() ); -------------- CTFE internal error: unsupported assignment *45 = 1 Assertion failed: (e1->op == TOKarraylength || e1->op == TOKvar || e1->op == TOKdotvar || e1->op == TOKindex || e1->op == TOKslice), function interpretAssignCommon, file interpret.c, line 3072. Abort trap: 6 -------------- The compiler should just fail to compile instead of ICE-ing. The number literal 45 can be replaced by a string literal and it still ICE. Test case 2: ----------------------- static assert( { auto k = cast(int*)45; *k = 1; return true; }() ); ----------------------- x.d(2): Error: CTFE internal error: illegal pointer value cast(int*)45u Assertion failed: (isStackValueValid(newval)), function createStackValue, file interpret.c, line 5165. ----------------------- Test case 3: ----------------------- static assert( { *cast(float*)"a" = 4.0; return true; }() ); ----------------------- CTFE internal error: unsupported assignment *cast(float*)"a" = 4F Assertion failed: (e1->op == TOKarraylength || e1->op == TOKvar || e1->op == TOKdotvar || e1->op == TOKindex || e1->op == TOKslice), function interpretAssignCommon, file interpret.c, line 3072. Abort trap: 6 ----------------------- (All test cases should *fail* to compile.)
Comment #1
by bugzilla — 2011-08-22T22:47:51Z
https://github.com/D-Programming-Language/dmd/commit/563a291a5c7757fca87685909afa37100e3b44f6