Bug 23406 – [seg fault] enums can cause compile time seg faults with assignments using alias this

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-10-12T02:58:07Z
Last change time
2022-10-17T03:00:42Z
Assigned to
No Owner
Creator
crazymonkyyy

Comments

Comment #0 by crazymonkyyy — 2022-10-12T02:58:07Z
``` struct flagenum{ int i=1;alias i this; auto opBinary(string s)(int j){ assert(j==1); return typeof(this)(i*2); } auto opEquals(int a){ return false; } } enum alphakey{a=flagenum(),b,c,d,e,f,g,h,i//,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z } alphakey alpha; void main(){ alpha=0; } ``` >[1] 52237 segmentation fault (core dumped) dmd segfualt.d I find that a 9th member causes the seg fault sus; but its the cut off point
Comment #1 by crazymonkyyy — 2022-10-12T03:02:57Z
``` auto opAssign(int j){ i=j; } ``` seems to prevent it btw
Comment #2 by razvan.nitu1305 — 2022-10-12T05:57:46Z
Comment #3 by crazymonkyyy — 2022-10-12T16:50:22Z
``` struct flagenum(I=ubyte){ I i=1; alias i this; auto opBinary(string s)(int j){ assert(j==1); return typeof(this)(cast(I)(i*2)); } auto opEquals(I a){ return false; } } enum alphakey{a=flagenum!int(),b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z } flagenum!int alpha; void main(){ alpha&=alphakey.a; } ``` causes the compiler to consume all computer resources is this the same bug?
Comment #4 by dlang-bot — 2022-10-12T17:56:15Z
dlang/dmd pull request #14546 "Fix Issue 23406 - [seg fault] enums can cause compile time seg faults with assignments using alias this" was merged into stable: - 3d1ce908e1850e248322ee330e038e8d99d5880a by RazvanN7: Fix Issue 23406 - [seg fault] enums can cause compile time seg faults with assignments using alias this https://github.com/dlang/dmd/pull/14546
Comment #5 by dlang-bot — 2022-10-17T03:00:42Z
dlang/dmd pull request #14573 "merge stable" was merged into master: - b9b7b1a33fb8b99ae180e904d51e8d1eb9b1b626 by RazvanN7: Fix Issue 23406 - [seg fault] enums can cause compile time seg faults with assignments using alias this https://github.com/dlang/dmd/pull/14573