Summary: Invalid union initializer is accepted
           Product: D
           Version: 1.040
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD

------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.


Reply via email to