[cfe-dev] False positive with -Wnull-dereference?

Sean McBride sean at rogue-research.com
Wed Jan 19 10:46:52 PST 2011


Hi all,

I'm trying to understand a warning given by r123839:

/freetype2/src/cache/ftccache.c:468:5: warning: indirection of non-
volatile null pointer will be deleted, not trap [-Wnull-dereference]
    FTC_CACHE_TRYLOOP_END( NULL );
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /freetype2/src/cache/ftcache.c:23:
In file included from /freetype2/src/cache/ftcmanag.c:21:
In file included from /freetype2/src/cache/ftcmanag.h:69:
/freetype2/src/cache/ftccache.h:336:9: note: instantiated from:
        *(FT_Bool*)( list_changed ) = TRUE;                       \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~

I think it's a false positive because the code is:

#define FTC_CACHE_TRYLOOP_END( list_changed )                     \
      if ( !error || error != FTC_Err_Out_Of_Memory )             \
        break;                                                    \
                                                                  \
      _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
      if ( _try_done > 0 && ( list_changed ) )                    \
        *(FT_Bool*)( list_changed ) = TRUE;                       \

Before dereferencing "list_changed" null is tested for.

Is the warning wrong?

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada






More information about the cfe-dev mailing list