Issue 24881 - ICE on attempt to compare deref of two functions ptr
Summary: ICE on attempt to compare deref of two functions ptr
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords: accepts-invalid, ice
Depends on:
Blocks:
 
Reported: 2024-11-25 19:35 UTC by basile-z
Modified: 2024-11-29 09:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description basile-z 2024-11-25 19:35:44 UTC
The following input

```
void function(int) a;
void function(int) b;

void main()
{
    const c = *a == *b;
    // assert(*a); // rejected during sema
}     
```

crashes dmd in the backend:

> TYD func
> 
> Program received signal SIGILL, Illegal instruction.
> 0x00005555559d1756 in dmd.backend.cod3.jmpopcode(dmd.backend.el.elem*) ()

I think however that the program is semantically invalid and should be rejected during exp-semantics, just like the commented assertion is.
Comment 1 basile-z 2024-11-25 19:46:36 UTC
Seems to happen only with `is`, comparisons, and relationals operators.
Comment 2 basile-z 2024-11-29 09:27:47 UTC
LDC2 crashes too since v1.35. Previously it generated bad code for `c` (see https://godbolt.org/z/cEM1MEevE), i.e `true` whatever the functions were pointing to.