D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6851 - [CTFE] Cannot deref pointer passed by argument
Summary: [CTFE] Cannot deref pointer passed by argument
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-10-25 05:09 UTC by Kenji Hara
Modified: 2011-11-03 16:00 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-10-25 05:09:15 UTC
void setn(int* pn)
{
    *pn = 20;
}
void test()
{
    int n = 0;
    auto pn = &n;
    *pn = 10;
    assert(n == 10);
    setn(&n);
}
static assert({ test(); return true; }());

----
Output:

test.d(3): Error: cannot dereference invalid pointer *pn
test.d(11):        called from here: setn(& n)
test.d(13):        called from here: test()
test.d(13):        called from here: delegate @system bool()
{
test();
return true;
}
()
test.d(13): Error: static assert  (delegate @system bool()
{
test();
return true;
}
()) is not evaluatable at compile time