[llvm-bugs] [Bug 39837] New: clang does not warn about nodiscard in a range-based for loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 29 05:58:16 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39837
Bug ID: 39837
Summary: clang does not warn about nodiscard in a range-based
for loop
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: blastrock at free.fr
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
clang does not issue a warning when compiling the following program:
#include <initializer_list>
struct [[nodiscard]] X {};
X f() { return {}; }
int main(int argc, char *argv[]) {
for (int const& i : {1})
f(); // Should warn here!
return 0;
}
Godbolt link: https://godbolt.org/z/7sAfXU
It does issue a warning if we put explicit braces in the for-loop body though.
--
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/20181129/7bfa302b/attachment.html>
More information about the llvm-bugs
mailing list