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
// Note: aSomeVec must be passed by value to trigger the problem, it seems.
// Changing to std::vector& reference silences the warning.
static bool
FuncThatTakesATemplatedArg(std::vector /* aSomeVec */)
{
return false;
}
int main()
{
std::vector myVec;
if ((false) &&
!FuncThatTakesATemplatedArg(myVec)) {
printf("Does clang warn about this code being unreachable?\n");
return 1;
}
return 0;
}
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users