[Issue 16447] New: Warn about auto return type when no return statement is present

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 31 01:14:56 PDT 2016


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 at puremagic.com
          Reporter: b2.temp at 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.

--


More information about the Digitalmars-d-bugs mailing list