Bug 22686 – ICE: dmd segfaults on invalid member reference in static function
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-01-17T19:15:51Z
Last change time
2022-01-21T07:05:58Z
Keywords
ice-on-invalid-code, pull
Assigned to
No Owner
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2022-01-17T19:15:51Z
Reduced code:
----------
struct S
{
int[] data;
static auto create()
{
auto self = &this;
return {
assert(data.length);
return self;
};
}
}
----------
Compiler version: DMD64 D Compiler v2.098.0-430-g8041bcdec
Compiler output:
----------
test.d(6): Error: `this` is only defined in non-static member functions, not `create`
Segmentation fault
----------
Expected behaviour: compiler should not segfault after rejecting the invalid code that tries to look up a non-static struct member from a static function.
This code was reduced from a larger module. I've tried to reduce this code as much as possible, but can't get farther than this. Removing the assert makes the segfault go away. Unwrapping the delegate also makes the segfault go away. The int[] array was reduced from an array of structs, but the array itself can't be removed or changed to a non-array type without making the segfault go away.
Comment #1 by moonlightsentinel — 2022-01-17T21:40:07Z
@RazvanN7 created dlang/dmd pull request #13557 "Fix Issue 22686 - ICE: dmd segfaults on invalid member reference in static function" fixing this issue:
- Fix Issue 22686 - ICE: dmd segfaults on invalid member reference in static function
https://github.com/dlang/dmd/pull/13557
Comment #3 by dlang-bot — 2022-01-21T07:05:58Z
dlang/dmd pull request #13557 "Fix Issue 22686 - ICE: dmd segfaults on invalid member reference in static function" was merged into stable:
- f4340597ca9efdbad27a3801e9b87030efc0bfc7 by RazvanN7:
Fix Issue 22686 - ICE: dmd segfaults on invalid member reference in static function
https://github.com/dlang/dmd/pull/13557