#if_MSC_VER#defineFATAL(format,...)do{fmt::print("{}:{} "format,__FILE__,__LINE__,##__VA_ARGS__);DebugBreak();abort();}while(1)#defineVERIFY(expression)do{if(!(expression)){FATAL("assert{}failedin{}", #expression, __func__); } } while (0)#else#define FATAL(format, ...) do { fmt::print("{}:{}" format, __FILE__, __LINE__, ##__VA_ARGS__); __builtin_trap(); __builtin_unreachable(); } while (1)#define VERIFY(expression) do { if (!(expression)) { FATAL("assert{}failedin{}",#expression,__func__);}}while(0)#endifvoidMenu::render(){Expects(m_application);auto*surface=m_application->get_context_window();VERIFY(surface!=nullptr);intiw=surface->get_width();intih=surface->get_height();
The last three lines seem to trigger cppcheck to complain that either check is redundant, or there can be a nullpointer dereference. What do I need to do to fix this? Thanks!
A guess: This is probably because CppCheck does not "know" that __builtin_trap() does not return. You may try using the --library option to point it to gnu.cfg
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is my code:
The last three lines seem to trigger cppcheck to complain that either check is redundant, or there can be a nullpointer dereference. What do I need to do to fix this? Thanks!
Actual code and cppcheck report: https://app.codacy.com/gh/tksuoran/erhe/issues?categoryType=ErrorProne
A guess: This is probably because CppCheck does not "know" that
__builtin_trap()
does not return. You may try using the--library
option to point it to gnu.cfg