[llvm-bugs] [Bug 39026] New: Spurious -Wreturn-type warning with "pathological" for

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 20 11:16:33 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39026

            Bug ID: 39026
           Summary: Spurious -Wreturn-type warning with "pathological" for
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthew.woehlke at kitware.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Consider the following code:

    int foo()
    {
        for (int y = 0; !y;)
            for (/*decl*/; !y; ++y)
                return 1;
    }

This generates a -Wreturn-type warning, despite that the inner loop body will
*always* execute. Moreover, with optimization enabled, the compiler does (as
expected) successfully remove the loops entirely.

(This is a simplified version of a pre-C++17 `with` statement. The purpose of
this code, which is usually a macro, is to look like the opening statement of a
block, where `/*decl*/` — omitted in this example — is in scope only until the
end of the block. FWIW, the C++17 form, `if (/*decl*/; true)` does not exhibit
the problem.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180920/fe48ae61/attachment.html>


More information about the llvm-bugs mailing list