Bug 2686 – Invalid union initializer is accepted

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-02-24T05:48:00Z
Last change time
2014-03-01T00:36:07Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
snake.scaly

Comments

Comment #0 by snake.scaly — 2009-02-24T05:48:20Z
------8<------- bug.d ---- static import std.stdio; union A { short a; long b; } void main() { A x = 0x12345; std.stdio.writefln("a %s, b %s", x.a, x.b); } ------8<------- bug.d ---- > dmd -run bug.d a 0, b 0 A simple numeric initializer is accepted but union members are not initialized accordingly. This should be a compile-time error.
Comment #1 by clugdbug — 2011-04-14T15:20:37Z
This was fixed in DMD1.050