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: kreme...@apple.com
          Reporter: socketp...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to