[llvm-bugs] [Bug 37392] New: Undesirable -Wrange-loop-analysis warning with auto and vector<bool>

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 9 06:37:02 PDT 2018


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

            Bug ID: 37392
           Summary: Undesirable -Wrange-loop-analysis warning with auto
                    and vector<bool>
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sean at rogue-research.com
                CC: llvm-bugs at lists.llvm.org

In clang 6.0 and trunk (according to godbolt), the following snippet generates
a warning from -Wrange-loop-analysis when building as C++11:

---------------------
#include <vector>

int main()
{
    std::vector<bool> vectorBool;

    for (auto&& elem : vectorBool)
        (void)elem;
}
---------------------

warning: loop variable 'elem' is always a copy because the range of type
'std::vector<bool>' does not return a reference [-Wrange-loop-analysis]
    for (auto&& elem : vectorBool)
                ^

See also: <https://godbolt.org/g/GQehmY>

Others seem to agree that the warning is not helpful:

<https://stackoverflow.com/questions/50066139/what-is-clangs-range-loop-analysis-diagnostic-about>

-- 
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/20180509/ab6a65f9/attachment.html>


More information about the llvm-bugs mailing list