Menu

False positive: Null pointer dereference

John Baker
2020-03-21
2020-03-31
  • John Baker

    John Baker - 2020-03-21
     
  • John Baker

    John Baker - 2020-03-21

    cppcheck 1.90 reports a null pointer dereference on this code:

    int p[10];
    p[9] = 5;
    for (int i=0, p=0; i<4; ++i)
      std::cout << i << " " << p << std::endl;
    std::cout << p[9] << std::endl;
    

    It thinks the p variables are the same.

     
  • Daniel Marjamäki

    thanks.. I created https://trac.cppcheck.net/ticket/9665

    not sure maybe it's a duplicate. but well now it's definitely reported.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.