[Issue 23055] New: importC: using compound-literal array as pointer in CTFE gives 'dereference of invalid pointer'
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 24 23:11:38 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23055
Issue ID: 23055
Summary: importC: using compound-literal array as pointer in
CTFE gives 'dereference of invalid pointer'
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE, ImportC
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: duser at neet.fi
CC: duser at neet.fi
int fn()
{
int *p = (int[1]){0};
*p = 0;
return *p;
}
_Static_assert(fn() == 0, "");
int main()
{
return fn();
}
test.c(4): Error: dereference of invalid pointer `[0]`
test.c(7): called from here: `fn()`
test.c(7): while evaluating: `static assert(fn() == 0)`
it works outside CTFE
--
More information about the Digitalmars-d-bugs
mailing list