[petsc-dev] clang --analyze messages on PETSc

Lisandro Dalcin dalcinl at gmail.com
Wed Apr 15 03:37:53 CDT 2015


On 15 April 2015 at 01:54, Barry Smith <bsmith at mcs.anl.gov> wrote:
>   I also don't understand why it would remove any warnings. Now PetscMalloc() could produce a zero pointer and so clang would still think that the pointer it uses later will be a null pointer deference. Why does moving the PetscMalloc1() handling of zero length to PetscMalloc() remove anything.

The analyzer does cross translations units. So, when you use the macro
PetscMalloc(), the analizer does not "see" what is happening in
PetscTrMallocDefault() or PetscMallocAlign(). However, if you use
PetscMalloc1(), and you special-case a zero-size allocation, there is
a code path where the pointer is NULL, then the analyzer complains.

-- 
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459



More information about the petsc-dev mailing list