www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22632] New: Crash happens when CTFE compares a struct

https://issues.dlang.org/show_bug.cgi?id=22632

          Issue ID: 22632
           Summary: Crash happens when CTFE compares a struct associative
                    array member to null using == when initialization
                    syntax used
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: msnmancini hotmail.com

Created attachment 1836
  --> https://issues.dlang.org/attachment.cgi?id=1836&action=edit
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

--
Dec 27 2021