Skip to content

false positive due to lack of bit-level constraints #4545

@llvmbot

Description

@llvmbot
Bugzilla Link 4173
Resolution DUPLICATE
Resolved on Feb 22, 2010 12:55
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @tkremenek,@xuzhongxing

Extended Description

scan-build gcc -Wall -O3 -c tst1.c

produce

ANALYZE: tst1.c foo
tst1.c:21:10: warning: Dereference of null pointer
pB->n = 0;
~~~~^
1 diagnostic generated.
scan-build: 1 bugs found.

cat tst1.c
#include <stdio.h>

struct blob {
int n;
void *p;
};

extern void bar(FILE**);

void foo(int x, int *y)
{
struct blob *pB = NULL;

if( !(x & 0x16) )
    bar((FILE**) (void*)&pB);

if( !(x & 0x16) ) {
    if(*y==0) {
        *y = 5;
    } else {
        pB->n = 0;
    }
}

}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions