Bug 10540 – variable used before set for empty static arrays, with -inline -O

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-04T02:15:00Z
Last change time
2017-07-19T03:28:32Z
Keywords
rejects-valid
Assigned to
nobody
Creator
monarchdodra
See also
http://d.puremagic.com/issues/show_bug.cgi?id=7953, https://issues.dlang.org/show_bug.cgi?id=7953, https://issues.dlang.org/show_bug.cgi?id=12212

Comments

Comment #0 by monarchdodra — 2013-07-04T02:15:47Z
Thread: http://forum.dlang.org/thread/[email protected]#post-khdhvzfdfljbtlyfqocw:40forum.dlang.org When compiled with -O -inline: -------- struct S { int[0] a; void do_it() { foo(a); } } void foo(Args...)(Args args) { //foreach(arg; args) // if (arg.ptr == null) // return; bar(args); } void bar(Args...)(Args args) { foreach(arg; args) if (arg.ptr == null) return; } void main() {} -------- Produces: main.d(11): Error: variable _param_0 used before set -------- Possibly the compiler optimizes out a's initialization, since it is an empty static array. Code is glitchy: Not only does the bug appear only in bar (and not foo), un-commenting the code in foo will *fix* the call in bar...
Comment #1 by monarchdodra — 2013-07-04T02:16:29Z
Comment #2 by dlang-bugzilla — 2017-07-19T03:28:24Z
No longer reproducible after https://github.com/dlang/dmd/pull/3467, closing. Please reopen if you can still provide a reproducible test case.