D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3264 - -O causes wrong "used before set" error when using enum.
Summary: -O causes wrong "used before set" error when using enum.
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: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-08-25 05:01 UTC by Don
Modified: 2015-06-09 01:28 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 Don 2009-08-25 05:01:40 UTC
OK when compiled normally, but when compiled with -O, generates:
interpret.d(2367): Error: variable Q used before set

--------

void bug()
{
    enum int Q=0;
    string [2] s = ["a", "b"];    
    assert(s[Q].dup=="a");
}
Comment 1 Walter Bright 2009-08-26 16:25:35 UTC
This bug does affect D1, but in different ways.
Comment 2 Walter Bright 2009-09-03 13:28:17 UTC
Fixed dmd 1.047 and 2.032