shouldn't this code at least trigger a warning?

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 28 23:37:44 PDT 2015


subj. the code:

  void main () {
    import std.stdio;
    char ch = '!';
    switch (ch) {
      int n = 42;
      case '!': writeln(n, ": wow!"); break;
      default:
    }
  }


i think that such abomination should:
1. be forbidden, or
2. trigger a warning, or
3. execute initializer anyway.

currently the code is allowed, no warnings triggered, yet `n` is 
uninitialized. and having uninitialized variable without "=void" "should 
not be".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150429/bcf23cf5/attachment-0001.sig>


More information about the Digitalmars-d-learn mailing list