[llvm-bugs] [Bug 36627] New: clang emits extraneous -Wunused-variable for RAII const reference variable
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 7 00:11:39 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36627
Bug ID: 36627
Summary: clang emits extraneous -Wunused-variable for RAII
const reference variable
Product: clang
Version: 5.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: anntzer.lee at gmail.com
CC: llvm-bugs at lists.llvm.org
Consider
struct S {
S();
~S(); // Assume this actually does some RAII cleanup.
};
extern int f();
int main() {
auto const t = S(); // No warning.
auto const& u = S(); // "warning: unused variable 'u'
[-Wunused-variable]".
f(); // Just so that clang has no way to know whether some work will
be done here.
}
and compile (e.g.) with `--std=c++17 -Wall -Wextra -Wpedantic`
clang (5.0.1 Arch Linux package) correctly recognizes that `t` could be
involved in RAII, but emits an unused-variable warning about `u` even though it
can also participate in RAII in the same way (as the lifetime of the const
reference is prolonged until the end of the scope). [Note that it would be a
different issue if clang neither recognized the possibility of RAII happening
for either `t` or `u`.]
--
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/20180307/04188bfc/attachment.html>
More information about the llvm-bugs
mailing list