Menu

#2604 error: array subscript '' is partly outside array bounds of '' [-Werror=array-bounds=]

open
nobody
None
5
2026-03-29
2025-11-04
No

compiling with gcc-16-20251005 has the following errors

/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++      -O2 -c -Werror -Wall -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC       -o _o/UserInputUtils.o ../../UI/Console/UserInputUtils.cpp
In file included from ../../Archive/../../Common/Common.h:11,
                 from ../../Archive/StdAfx.h:9,
                 from ../../Archive/HandlerCont.cpp:3:
In destructor 'CLocalProgress::~CLocalProgress()',
    inlined from 'virtual ULONG CLocalProgress::Release()' at ../../Archive/../Common/ProgressUtils.h:11:1,
    inlined from 'CMyComPtr<T>::~CMyComPtr() [with T = ICompressProgressInfo]' at ../../Archive/../Common/../../Common/MyCom.h:17:37,
    inlined from 'virtual LONG NArchive::CHandlerImg::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/HandlerCont.cpp:283:5:
../../Archive/../Common/ProgressUtils.h:12:3: error: array subscript 'CLocalProgress[0]' is partly outside array bounds of 'unsigned char [32]' [-Werror=array-bounds=]
   12 |   CLocalProgress
      |   ^~~~~~~~~~~~~~
../../Archive/../../Common/Common0.h:207:34: note: in definition of macro 'Z7_class_final'
  207 | #define Z7_class_final(c)  class c Z7_final
      |                                  ^
../../Archive/../Common/ProgressUtils.h:11:1: note: in expansion of macro 'Z7_CLASS_IMP_COM_1'
   11 | Z7_CLASS_IMP_COM_1(
      | ^~~~~~~~~~~~~~~~~~
../../Archive/HandlerCont.cpp: In member function 'virtual LONG NArchive::CHandlerImg::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
../../Archive/HandlerCont.cpp:278:75: note: object of size 32 allocated by 'operator new'
  278 |       CHandlerImgProgress *imgProgressSpec = new CHandlerImgProgress(*this);
      |                                                                           ^
cc1plus: all warnings being treated as errors
make: *** [../../7zip_gcc.mak:536: _o/HandlerCont.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../../Archive/Rar/../../Common/CreateCoder.h:6,
                 from ../../Archive/Rar/RarHandler.cpp:17:
In member function 'virtual ULONG CFilterCoder::AddRef()',
    inlined from 'T* CMyComPtr<T>::operator=(T*) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:27:16,
    inlined from 'T* CMyComPtr<T>::operator=(const CMyComPtr<T>&) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:33:56,
    inlined from 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/Rar/RarHandler.cpp:1679:21:
../../Archive/Rar/../../Common/../../Common/MyCom.h:383:16: error: array subscript 'CFilterCoder[0]' is partly outside array bounds of 'unsigned char [72]' [-Werror=array-bounds=]
  383 |     { return ++_m_RefCount; } \
      |                ^~~~~~~~~~~
../../Archive/Rar/../../Common/FilterCoder.h:163:3: note: in expansion of macro 'Z7_COM_ADDREF_RELEASE'
  163 |   Z7_COM_ADDREF_RELEASE
      |   ^~~~~~~~~~~~~~~~~~~~~
../../Archive/Rar/RarHandler.cpp: In member function 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
../../Archive/Rar/RarHandler.cpp:1464:57: note: object of size 72 allocated by 'operator new'
 1464 |   NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
      |                                                         ^~~~~~~~~~
In member function 'virtual ULONG CFilterCoder::AddRef()',
    inlined from 'T* CMyComPtr<T>::operator=(T*) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:27:16,
    inlined from 'T* CMyComPtr<T>::operator=(const CMyComPtr<T>&) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:33:56,
    inlined from 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/Rar/RarHandler.cpp:1679:21:
../../Archive/Rar/../../Common/../../Common/MyCom.h:383:16: error: array subscript 'CFilterCoder[0]' is partly outside array bounds of 'unsigned char [72]' [-Werror=array-bounds=]
  383 |     { return ++_m_RefCount; } \
      |                ^~~~~~~~~~~
../../Archive/Rar/../../Common/FilterCoder.h:163:3: note: in expansion of macro 'Z7_COM_ADDREF_RELEASE'
  163 |   Z7_COM_ADDREF_RELEASE
      |   ^~~~~~~~~~~~~~~~~~~~~
../../Archive/Rar/RarHandler.cpp: In member function 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
../../Archive/Rar/RarHandler.cpp:1464:57: note: object of size 72 allocated by 'operator new'
 1464 |   NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
      |                                                         ^~~~~~~~~~
cc1plus: all warnings being treated as errors
make: *** [../../7zip_gcc.mak:663: _o/RarHandler.o] Error 1
make: Leaving directory '/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/7-zip-25.01/.x86_64-libreelec-linux-gnu/CPP/7zip/Bundles/Alone2'
FAILURE: s/build 7-zip during make_target (package.mk)

Discussion

  • Igor Pavlov

    Igor Pavlov - 2025-11-04

    I don't understand that error.
    What about another gcc versions?
    what version of 7-Zip do you compile?

     
  • Rudi Heitbaum

    Rudi Heitbaum - 2026-02-12

    retested with 26.00 release and gcc-16-20260208

    below is the error output.

    In file included from ../../Archive/../../Common/Common.h:11,
                     from ../../Archive/StdAfx.h:9,
                     from ../../Archive/HandlerCont.cpp:3:
    In destructor 'CLocalProgress::~CLocalProgress()',
        inlined from 'virtual ULONG CLocalProgress::Release()' at ../../Archive/../Common/ProgressUtils.h:11:1,
        inlined from 'CMyComPtr<T>::~CMyComPtr() [with T = ICompressProgressInfo]' at ../../Archive/../Common/../../Common/MyCom.h:17:37,
        inlined from 'virtual LONG NArchive::CHandlerImg::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/HandlerCont.cpp:283:5:
    ../../Archive/../Common/ProgressUtils.h:12:3: error: array subscript 'CLocalProgress[0]' is partly outside array bounds of 'unsigned char [32]' [-Werror=array-bounds=]
       12 |   CLocalProgress
          |   ^~~~~~~~~~~~~~
    ../../Archive/../../Common/Common0.h:208:34: note: in definition of macro 'Z7_class_final'
      208 | #define Z7_class_final(c)  class c Z7_final
          |                                  ^
    ../../Archive/../Common/ProgressUtils.h:11:1: note: in expansion of macro 'Z7_CLASS_IMP_COM_1'
       11 | Z7_CLASS_IMP_COM_1(
          | ^~~~~~~~~~~~~~~~~~
    ../../Archive/HandlerCont.cpp: In member function 'virtual LONG NArchive::CHandlerImg::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
    ../../Archive/HandlerCont.cpp:278:75: note: object of size 32 allocated by 'operator new'
      278 |       CHandlerImgProgress *imgProgressSpec = new CHandlerImgProgress(*this);
          |                                                                           ^
    cc1plus: all warnings being treated as errors
    make: *** [../../7zip_gcc.mak:536: _o/HandlerCont.o] Error 1
    make: *** Waiting for unfinished jobs....
    In file included from ../../Archive/Rar/../../Common/CreateCoder.h:6,
                     from ../../Archive/Rar/RarHandler.cpp:18:
    In member function 'virtual ULONG CFilterCoder::AddRef()',
        inlined from 'T* CMyComPtr<T>::operator=(T*) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:27:16,
        inlined from 'T* CMyComPtr<T>::operator=(const CMyComPtr<T>&) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:33:56,
        inlined from 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/Rar/RarHandler.cpp:1695:21:
    ../../Archive/Rar/../../Common/../../Common/MyCom.h:383:16: error: array subscript 'CFilterCoder[0]' is partly outside array bounds of 'unsigned char [72]' [-Werror=array-bounds=]
      383 |     { return ++_m_RefCount; } \
          |                ^~~~~~~~~~~
    ../../Archive/Rar/../../Common/FilterCoder.h:163:3: note: in expansion of macro 'Z7_COM_ADDREF_RELEASE'
      163 |   Z7_COM_ADDREF_RELEASE
          |   ^~~~~~~~~~~~~~~~~~~~~
    ../../Archive/Rar/RarHandler.cpp: In member function 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
    ../../Archive/Rar/RarHandler.cpp:1480:57: note: object of size 72 allocated by 'operator new'
     1480 |   NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
          |                                                         ^~~~~~~~~~
    In member function 'virtual ULONG CFilterCoder::AddRef()',
        inlined from 'T* CMyComPtr<T>::operator=(T*) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:27:16,
        inlined from 'T* CMyComPtr<T>::operator=(const CMyComPtr<T>&) [with T = ICompressCoder]' at ../../Archive/Rar/../../Common/../../Common/MyCom.h:33:56,
        inlined from 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)' at ../../Archive/Rar/RarHandler.cpp:1695:21:
    ../../Archive/Rar/../../Common/../../Common/MyCom.h:383:16: error: array subscript 'CFilterCoder[0]' is partly outside array bounds of 'unsigned char [72]' [-Werror=array-bounds=]
      383 |     { return ++_m_RefCount; } \
          |                ^~~~~~~~~~~
    ../../Archive/Rar/../../Common/FilterCoder.h:163:3: note: in expansion of macro 'Z7_COM_ADDREF_RELEASE'
      163 |   Z7_COM_ADDREF_RELEASE
          |   ^~~~~~~~~~~~~~~~~~~~~
    ../../Archive/Rar/RarHandler.cpp: In member function 'virtual LONG NArchive::NRar::CHandler::Extract(const UInt32*, UInt32, Int32, IArchiveExtractCallback*)':
    ../../Archive/Rar/RarHandler.cpp:1480:57: note: object of size 72 allocated by 'operator new'
     1480 |   NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
          |                                                         ^~~~~~~~~~
    cc1plus: all warnings being treated as errors
    make: *** [../../7zip_gcc.mak:663: _o/RarHandler.o] Error 1
    
     
  • Igor Pavlov

    Igor Pavlov - 2026-02-13

    I suppose it's GCC-16 compiler bug.
    There are two different classes in 7-zip code:
    CHandlerImgProgress and CLocalProgress.
    Both these classes have same base class interface ICompressProgressInfo.
    But GCC-16 compiler doesn't like that sizes of objects of these classes also are different. Maybe compiler tries to optimize the code and works incorrectly.

    You can try to report that issue to GCC-16 developers.

     

    Last edit: Igor Pavlov 2026-02-13
  • Igor Pavlov

    Igor Pavlov - 2026-03-29

    GCC16 shows the warning, if we have 2 classes:
    CHandlerImgProgress and CLocalProgress.
    If we have only one class, there was no error.
    If we add some dummy variables to one of these classes, it also work.
    So I think that it's bug in GCC16.

     

Log in to post a comment.