5239 – optimizer misreports an used before set error

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5239 - optimizer misreports an used before set error
Summary: optimizer misreports an used before set error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2010年11月18日 22:34 UTC by Brad Roberts
Modified: 2011年08月03日 17:13 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2010年11月18日 22:34:20 UTC
(an excerpt from runnable/interpret.d)
struct S { int x; }
template Compileable(int z) { bool OK=true;}
int goodfoo3()
{
 S[4] w = void; // uninitialized array of structs
 w[$-2].x = 217; // initialize one member
 return w[2].x; // line 8
}
$ dmd -c -O f.d
f.d(8): Error: variable w used before set
note: filed as d2, but might well exist on d1 as well.. untested
Comment 1 Brad Roberts 2011年08月03日 00:06:43 UTC
Part of the test case for bug 6293 triggers this bug when built with -O. See runnable/xtet46.d, test6293(). The buggy part is hidden behind version(none).
class C6293 {
 C6293 token;
}
void f6293(in C6293[] a) pure {
 auto x0 = a[0].token;
 assert(x0 is a[0].token.token.token);
 assert(x0 is (&x0).token);
 version(none) {
 auto p1 = &x0 + 1;
 assert(x0 is (p1 - 1).token);
 }
 int c = 0;
 assert(x0 is a[c].token);
}
void test6293() {
 auto x = new C6293;
 x.token = x;
 f6293([x]);
}
See also:
 https://github.com/D-Programming-Language/dmd/pull/243 


AltStyle によって変換されたページ (->オリジナル) /