stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Zhong" <Scott.Zh...@roguewave.com>
Subject [TESTCASE] STDCXX-750 [HP aCC 6.16] Potential null pointer dereference in aliases.cpp
Date Thu, 20 Mar 2008 17:50:05 GMT
cat /build/scottz/t2.cpp && aCC -V && aCC -c  +w  /build/scottz/t2.cpp 
#include <cstdlib>

int main()
{
  static char * test = 0;
  if (!test) {
     test = (char *)std::malloc (12345);
     *test = '\0';
  }

  return 0;
}
aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
"/build/scottz/t2.cpp", line 8, procedure main: warning #20200-D:
Potential
          null pointer dereference through test is detected (null
          definition:/build/scottz/t2.cpp, line 7)

this test case shows that the warning is bogus because the pointer
"test" is pointing to a valid location in memory after std::malloc is
performed.

Mime
View raw message