www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16447] New: Warn about auto return type when no return

https://issues.dlang.org/show_bug.cgi?id=16447

          Issue ID: 16447
           Summary: Warn about auto return type when no return statement
                    is present
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

When an auto function contains no return statement a warning could be emitted.

example:

auto foo(int x)
{
    asm
    {
        naked;
        add RAX, 1;
        ret;
    }
}

The return type here is "void". Other case can exist, even w/o iasm, where the
coder can get strange and inaccurate error message if he's forget his return
statement(s).

- When an auto function, depending on the static if conditions, returns void or
something then no warning, b/c to return the something a return statement is
present.
- When an auto function returns void and contains no return statement, warn.

--
Aug 31 2016