Menu

From version 1.85, Cppcheck crashes on sizeof(arr)/sizeof(arr[0]), arr - large static array

Vladimir
2019-02-13
2019-02-14
  • Vladimir

    Vladimir - 2019-02-13

    code example (tested on Windows7):
    static float arr[] = {0, .../ 70 000 times /, 0};
    sizeof(arr)/sizeof(arr[0]);

     
  • versat

    versat - 2019-02-13

    I can not reproduce it with the latest sources. I tried the normal 64 bit build and even a 32 bit build, but it processes it without problems.
    I have attached the file i used for testing.
    Can you check if it crashes with it on your system?
    Do you use a 64 bit Windows 7?

     
  • Vladimir

    Vladimir - 2019-02-14

    Sorry for my mistake, you should change the last line in your cpp-file to the following (float instead of arr[0]):
    size_t arrsize = sizeof(arr)/sizeof(float);
    I use Windows 7, 64bit, Cppcheck 1.87 (the last version which doesn't crash is 1.84).

     
    • versat

      versat - 2019-02-14

      Ah ok, then i can also reproduce it.
      gdb output:

      (gdb) r
      Starting program: cppcheck arrsize.cpp
      [New Thread 9836.0x2964]
      [New Thread 9836.0x720]
      [New Thread 9836.0x2454]
      [New Thread 9836.0x2b98]
      Checking arrsize.cpp ...
      
      Thread 1 "cppcheck" received signal SIGSEGV, Segmentation fault.
      0x00000001005c9605 in Token::isName (this=0x6036ed0e0) at lib/token.h:339
      339             return getFlag(fIsName);
      
       
  • versat

    versat - 2019-02-14

    Thanks for your report, i will create a ticket for this issue.
    I attach the file with which i can reproduce the issue and that is processed by gcc without warnings but still crashes Cppcheck.

     
    • versat

      versat - 2019-02-14
       

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.