[cfe-users] -Wunreachable-code warnings can no longer be suppressed?
Chris Peterson via cfe-users
cfe-users at lists.llvm.org
Tue Aug 9 13:09:01 PDT 2016
On 8/6/16 9:50 AM, David Blaikie wrote:
> Could you provide a small example that fails (warns/doesn't suppress) with 3.9/ToT but succeeds (successfully suppresses the warning) with earlier?
Thanks for testing, David. Below is a standalone test case that
reproduces the insuppressible warning even with Xcode's clang (Apple
LLVM version 7.3.0 (clang-703.0.31)). So there is a latent clang bug
plus a regression that caused Firefox's previously-suppressible warning
to no longer be suppressible.
The warning looks like it might only happen when the boolean condition
involves an expression with a templated type. In the test case below, a
templated local variable gets copy-constructed to form an argument to a
boolean helper-function.
I filed clang bug 28918 for this issue:
https://llvm.org/bugs/show_bug.cgi?id=28918
$ clang++ -Wunreachable-code test.cpp
test.cpp:23:5: warning: code will never be executed [-Wunreachable-code]
printf("Does clang warn about this code being unreachable?\n");
^~~~~~
1 warning generated.
thanks,
chris
// Compile me like so:
// clang++ -Wunreachable-code test.cpp
// and see if I produce a build warning.
//
// Note that if you change aSomeVec to be a non-templated type, then
// the build warning goes away.
#include "stdio.h"
#include <vector>
// Note: aSomeVec must be passed by value to trigger the problem, it seems.
// Changing to std::vector<int>& reference silences the warning.
static bool
FuncThatTakesATemplatedArg(std::vector<int> /* aSomeVec */)
{
return false;
}
int main()
{
std::vector<int> myVec;
if ((false) &&
!FuncThatTakesATemplatedArg(myVec)) {
printf("Does clang warn about this code being unreachable?\n");
return 1;
}
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20160809/ea692ed0/attachment.html>
More information about the cfe-users
mailing list