D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6919 - [CTFE] Cannot get effect to local variable through its pointer
Summary: [CTFE] Cannot get effect to local variable through its pointer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 03:27 UTC by Kenji Hara
Modified: 2011-11-16 11:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2011-11-09 03:27:55 UTC
void formattedRead(int* val)
{
    *val = 1;
}
void test()
{
    int n;
    formattedRead(&n);
    assert(n == 1);  // fails!
}
static assert({ test(); return true; }());
Comment 1 Kenji Hara 2011-11-09 04:52:09 UTC
Similar code.

void formattedRead(string* val)
{
    *val = "1";
}

void test()
{
    string val;
    formattedRead(&val);
    assert(val == "1");
}
static assert({ test(); return true; }());