Bug 12034 – Union and inlining leads to erroneous "Error: variable used before set"
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-29T10:59:00Z
Last change time
2015-10-26T13:17:17Z
Assigned to
nobody
Creator
aliloko
Comments
Comment #0 by aliloko — 2014-01-29T10:59:06Z
How to reproduce:
---
import std.numeric;
alias CustomFloat!16 half_t;
union half_ushort
{
half_t f;
ushort i;
}
void fun()
{
half_t asHalf = 0;
half_ushort hu = void;
hu.f = asHalf;
}
---
Present in both DMD 2.065b2 and DMD 2.064.
Comment #1 by aliloko — 2014-01-29T10:59:59Z
Compile with:
$ dmd testcase.d -O -inline
Comment #2 by aliloko — 2015-09-11T19:43:49Z
DMD v2.068.0 refuses this program with:
test.d(15): Error: variable hu used before set
Not sure if intended because the whole variable is written with
hu.f = asHalf;