I ran into this issue as well, and spent some time trying to figure it out, but I could not see a way to disable this type of warning in clang-tidy.
From reading this discussion on the LLVM issue tracker regarding a similar issue, I get the impression that the problem is that from clang-tidy’s perspective, the warning is actually located in main.cpp
, because the call to set_value
is from there.
My workaround has been to disable the static analysis checks in clang-tidy, and use the scan-build utility to run clang’s static analysis, which seems to avoid these problems. For example, using your main.cpp
:
$ scan-build-3.9 clang++ -std=c++14 main.cpp
scan-build: Using '/usr/lib/llvm-3.9/bin/clang' for static analysis
In file included from main.cpp:1:
In file included from /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/future:39:
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/mutex:621:11: warning: Address of stack memory associated with local variable '__callable' is still referred to by the global variable '__once_callable' upon returning to the caller. This will be a dangling reference
if (__e)
^~~
1 warning generated.
scan-build: Removing directory '/tmp/scan-build-2017-12-02-112018-13035-1' because it contains no reports.
scan-build: No bugs found.
The analyzer finds the same error in a system header, but it’s smart enough not to include it in the final report. (“No bugs found”)
You’ll still need to run clang-tidy separately if you are interested in the style guide type warnings, like modernize-*
or readability-*
.