From c2c9c94d5e2f1f5a969a881e489a3deaf0d57f36 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 26 Feb 2018 07:02:54 -0800 Subject: [PATCH] [bug] notice we do not support some versions of `assert` Summary: Ran into this issue on Debian Testing, in which assert.h is probably different due to a more recent toolchain. Without this change I get the following CFG for `assert(e)`: ``` start |-> prune (e) -> join |-> prune (!e) -> __infer_fail("ASSERTION_FAILURE") -> exit ``` Notice that the first branch does not get to the exit, so infer must think that the assertion is *always* violated, and reports `error: ASSERTION_FAILURE`. This is broken. Reviewed By: dulmarod Differential Revision: D7067822 fbshipit-source-id: a2bf5ac --- .../codetoanalyze/c/errors/assertions/assertion_example.c | 3 +++ .../codetoanalyze/c/errors/assertions/assertion_failure.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/infer/tests/codetoanalyze/c/errors/assertions/assertion_example.c b/infer/tests/codetoanalyze/c/errors/assertions/assertion_example.c index e022631df..e3112b51e 100644 --- a/infer/tests/codetoanalyze/c/errors/assertions/assertion_example.c +++ b/infer/tests/codetoanalyze/c/errors/assertions/assertion_example.c @@ -7,6 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +// TODO: remove this #define, it's here to get a specific version of +// [assert], as others may confuse the clang frontend (t26324545) +#define __STRICT_ANSI__ #include // We should report here no NPE, but also we should report div0 to show that we diff --git a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c index 50e63413f..910071469 100644 --- a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c +++ b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c @@ -7,6 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +// TODO: remove this #define, it's here to get a specific version of +// [assert], as others may confuse the clang frontend (t26324545) +#define __STRICT_ANSI__ #include #include