[Issue 3163] New: Never referenced local variable compiles without error.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 10 16:11:16 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3163

           Summary: Never referenced local variable compiles without
                    error.
           Product: D
           Version: 2.029
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: peng2cheng2 at yahoo.com


Per Paragraph 2, "Local Variables" in "Functions" DMD 2.0, it is an error to
declare a local variable that is never referred to. But this compiles and runs
fine:

--- code

import std.stdio;

void main(){ 
    int i = 10; //never referred to -- should be error ?
    int k;
    writefln("%d", i + 3);
}

--- terminal

ex$> /opt/dmd2/linux/bin/dmd2

Digital Mars D Compiler v2.029
Copyright (c) 1999-2009 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html

ex$> /opt/dmd2/linux/bin/dmd2 func.d
ex$> ./func
13

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list