[llvm-bugs] [Bug 30679] New: scan-build did not found error on simple program with assert()
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 12 11:57:47 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30679
Bug ID: 30679
Summary: scan-build did not found error on simple program with
assert()
Product: clang
Version: 3.8
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: socketpair at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
#include <stdio.h>
#include <assert.h>
static void show(const char *const msg)
{
assert(msg != NULL);
printf("msg=%s\n", msg);
}
int main(void)
{
show("qwe");
show(NULL);
show("asd");
return 0;
}
==================================
scan-build finds no error in this code. But finds other errors (like possibly
memory leakage when I explicitly add such error in the code.
=============
scan-build-3.8 gcc qwe.c
scan-build: Using '/usr/lib/llvm-3.8/bin/clang' for static analysis
scan-build: Removing directory '/tmp/scan-build-2016-10-13-000037-5639-1'
because it contains no reports.
scan-build: No bugs found.
=============
qwe.i: (no difference on gcc and clang except whitespaces)
...
(!)!!!!!! note __noreturn__ and http://clang-analyzer.llvm.org/annotations.html
!!!!!
# 69 "/usr/include/assert.h" 3 4
extern void __assert_fail (const char *__assertion, const char *__file,
unsigned int __line, const char *__function)
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
...
static void show(const char *const msg)
{
((msg != ((void *)0)) ? (void) (0) : __assert_fail ("msg != NULL", "qwe.c",
7, __PRETTY_FUNCTION__))
printf("msg=%s\n", msg);
}
...
=================
--
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/20161012/6359e606/attachment.html>
More information about the llvm-bugs
mailing list