[llvm-bugs] [Bug 40417] New: diagnose_if should try harder to find violations
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 22 16:10:13 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40417
Bug ID: 40417
Summary: diagnose_if should try harder to find violations
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: redbeard0531 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
This code compiles without warnings, even though (at least with -O2) the
compiler clearly knows that that there are violations since it is emitting
unchecked calls to boom(). This makes this feature much less useful since it
can only catch direct violations, which are the most likely to be noticed by
humans. It would be much more useful as a general static analysis hint if some
of these other cases could also be detected and warned on. The last example is
particularly interesting to us because it is a slightly simplified version of
where we tried to use diagnose_if until we saw that it was unable to detect
anything.
https://godbolt.org/z/QfCCux
void boom();
inline void semi_static_assert(bool arg)
__attribute__((diagnose_if(!arg, "boom", "warning"))) {
if (!arg) boom();
}
inline bool always_false() {return false;}
struct bool_holder {
bool is_true() const { return b; }
bool b;
};
void test() {
// semi_static_assert(false); // warns
// no warnings from the rest
semi_static_assert(always_false());
bool also_false = false;
semi_static_assert(also_false);
semi_static_assert(bool_holder{false}.is_true());
}
--
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/20190123/5b6501b3/attachment.html>
More information about the llvm-bugs
mailing list