Bug 22632 – Crash happens when CTFE compares an associative array to null using ==

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-12-27T16:33:06Z
Last change time
2022-01-01T00:05:58Z
Keywords
CTFE, ice-on-valid-code, pull
Assigned to
No Owner
Creator
Marcelo Silva Nascimento Mancini

Attachments

IDFilenameSummaryContent-TypeSize
1836unknown.pngonlineapp.d(22): Error: CTFE internal error: bad compare of `["tt":Helper("hello world")]` and `null` Illegal instruction (core dumped)image/png12382

Comments

Comment #0 by msnmancini — 2021-12-27T16:33:06Z
Created attachment 1836 onlineapp.d(22): Error: CTFE internal error: bad compare of `["tt":Helper("hello world")]` and `null` Illegal instruction (core dumped) Attached the image proving the crash The error message I got was CTFE internal error: bad compare of `["hipengine_api":Dependency("../../api")]` and `null` It is an associative array of string:struct. ```d import std; struct Helper { string hello; } struct OurComposition { string compositionName; Helper[string] helpers; } enum OurComposition test = { compositionName : "Tester", helpers : [ "tt" : Helper("hello world") ] }; enum hasHelper = test.helpers != null; void main() { writeln("Hello D. ", hasHelper); } ``` I believe this is a real corner case, it didn't happen until I used a struct initialization syntax
Comment #1 by wolframw — 2021-12-27T22:43:43Z
This can be easily reproduced with an AA literal, no structs necessary: https://run.dlang.io/gist/32e6bbd4cd2b3c6e339234ec30ccfe92 It looks like CTFE doesn't cover comparisons of AA literals with null.
Comment #2 by dlang-bot — 2021-12-27T22:57:40Z
@wolframw created dlang/dmd pull request #13465 "Fix issue 22632 - Crash happens when CTFE compares an associative arr…" fixing this issue: - Fix issue 22632 - Crash happens when CTFE compares an associative array to null using == https://github.com/dlang/dmd/pull/13465
Comment #3 by dlang-bot — 2022-01-01T00:05:58Z
dlang/dmd pull request #13465 "Fix issue 22632 - Crash happens when CTFE compares an associative arr…" was merged into master: - c238e37f54a937c416a586330e551306a7c74a2d by wolframw: Fix issue 22632 - Crash happens when CTFE compares an associative array to null using == https://github.com/dlang/dmd/pull/13465