Comment #0 by a.horodniceanu — 2022-03-25T21:10:03Z
---
char[] s = "hello".dup;
void main () {
s[0] = 'X'; // segfault
}
---
---
char[] h () {
return ['h'];
}
char[] s = h() ~ "i";
void main () {
s[0] = 'X'; // segfault
}
---
These bugs seem to be caused due to CTFE evaluating expresions to a diferent type than what would be produced at runtime:
---
char[] h () {
return ['h'];
}
void main () {
// Literals seem to be evaluated similarly to runtime
pragma(msg, (['h'] ~ "i").ptr); // &['h', 'i'][0]
pragma(msg, (h() ~ "i").ptr); // &"hi"[0]
}
---
Comment #1 by robert.schadek — 2024-12-13T19:21:42Z