[Issue 13295] New: [CTFE] Modifications of const user type disappear
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 15 05:47:37 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13295
Issue ID: 13295
Summary: [CTFE] Modifications of const user type disappear
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE, wrong-code
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: verylonglogin.reg at gmail.com
This code should compile fine:
---
struct S
{
int n;
}
void f(ref const S s)
{
*cast(int*) &s.n = 1;
// assert(s.n == 1); // will also fail
}
void main()
{
static assert(
{
S s;
f(s);
return s.n == 1; // false, s.n is 0
} ());
}
---
--
More information about the Digitalmars-d-bugs
mailing list