Menu

Help with error

Marc Zim
2022-06-03
2022-06-11
  • Marc Zim

    Marc Zim - 2022-06-03

    Hello,

    I have an error I don't understand with attached cpp file.

    new3.cpp:22:14: error: Memory is allocated but not initialized: nc [uninitdata]
    delete[] nc;

    I don't get two things:
    - first why this error (assuming intersection function fills the values of xc, yc, nc)
    - second why xc, yc are not seen uninitialized like nc

    Thanks for your help.

     
  • Marc Zim

    Marc Zim - 2022-06-03

    command line to reproduce the problem: cppcheck new3.cpp --enable=all

     
  • CHR

    CHR - 2022-06-03

    nc is only used conditionally inside the first ifblock. yc and yc are used in two places.

     
  • Daniel Marjamäki

    thanks for reporting. I don't think that we should warn about delete[] nc; even if the nc data is uninitialized. I have created this ticket: https://trac.cppcheck.net/ticket/11132

     

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.