www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3163] New: Never referenced local variable compiles without error.

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: peng2cheng2 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: -------
Jul 10 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3163


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                URL|                            |http://www.digitalmars.com/
                   |                            |d/1.0/function.html
                 CC|                            |smjg iname.com
           Platform|Other                       |All
            Version|2.029                       |1.046
         OS/Version|Linux                       |All




--- Comment #1 from Stewart Gordon <smjg iname.com>  2009-07-14 16:37:48 PDT ---
Uh, your comment is on the wrong line.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3163


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE


--- Comment #2 from yebblies <yebblies gmail.com> 2011-06-10 11:14:55 PDT ---
*** This issue has been marked as a duplicate of issue 3960 ***

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