[llvm-bugs] [Bug 37767] New: LLVM_NODISCARD does not work in for loops.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 11 07:09:06 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37767
Bug ID: 37767
Summary: LLVM_NODISCARD does not work in for loops.
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Support Libraries
Assignee: unassignedbugs at nondot.org
Reporter: gchatelet at google.com
CC: llvm-bugs at lists.llvm.org
See the following snippe (https://godbolt.org/g/DxoBaC)
> #include "llvm/Support/Error.h"
>
> struct A {
> llvm::Error foo() const;
> };
>
> void bar(llvm::ArrayRef<A> As) {
> for(const auto& A : As)
> A.foo(); // No warning.
> }
>
> void baz(llvm::ArrayRef<A> As) {
> As.front().foo(); // Warning.
> }
llvm::Error is marked LLVM_NODISCARD and should generate a warning if not
consumed.
`baz` generates a warning with clang but `bar` does not.
When using gcc, no warning is generated at all.
--
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/20180611/cc344d06/attachment.html>
More information about the llvm-bugs
mailing list