Menu

[MSVC] Cppcheck build failed under msvc x86 mode due to error C2118: negative subscript

June Liu
2022-06-28
2022-06-29
  • June Liu

    June Liu - 2022-06-28

    Issue description:
    Hi,
    Recently, we updated the commit of Cppcheck, and it built failed under msvc x86 mode due to the errors like below. Could you please take a look? Thanks.

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\vcruntime.h(193,30): error C2371: 'size_t': redefinition; different basic types (compiling source file F:\gitP\danmar\cppcheck\cli\filelister.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\vcruntime.h(193,30): error C2371: 'size_t': redefinition; different basic types (compiling source file F:\gitP\danmar\cppcheck\cli\threadexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\vcruntime.h(193,30): error C2371: 'size_t': redefinition; different basic types (compiling source file F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\vcruntime.h(193,30): error C2371: 'size_t': redefinition; different basic types (compiling source file F:\gitP\danmar\cppcheck\cli\cmdlineparser.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xlocale(2084,39): error C2672: 'std::min': no matching overloaded function found (compiling source file F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xlocale(2285,39): error C2672: 'std::min': no matching overloaded function found (compiling source file F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xlocale(2084,39): error C2672: 'std::min': no matching overloaded function found (compiling source file F:\gitP\danmar\cppcheck\cli\cmdlineparser.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xlocale(2084,39): error C2672: 'std::min': no matching overloaded function found (compiling source file F:\gitP\danmar\cppcheck\cli\threadexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xlocale(2285,39): error C2672: 'std::min': no matching overloaded function found (compiling source file F:\gitP\danmar\cppcheck\cli\threadexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(41,5): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(69,9): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(41,5): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\cmdlineparser.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(69,9): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\cmdlineparser.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(41,5): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\threadexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xbit_ops.h(69,9): error C3861: '_BitScanReverse64': identifier not found (compiling source file F:\gitP\danmar\cppcheck\cli\threadexecutor.cpp) [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
             F:\gitP\danmar\cppcheck\cli\cppcheckexecutor.cpp(715,88): error C2118: negative subscript [F:\gitP\danmar\cppcheck\build_x86\cli\cli_objs.vcxproj]
    

    Excepted result:
    build successfully.

    Repro steps:
    1. git clone https://github.com/danmar/cppcheck F:\gitP\danmar\cppcheck
    2. mkdir F:\gitP\danmar\cppcheck\build_x86 and cd F:\gitP\danmar\cppcheck\build_x86
    3. cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release
    4. msbuild /m /p:Platform=Win32 /p:Configuration=Release Cppcheck.sln /t:Rebuild 2>&1

    More info:
    Windows: windows server 2019
    VS: VS2019 (vs16.11.11)
    The commit of Cppcheck we currently use: 343d04f, it reported error as above.
    The earlier commit: dbc8078 is built fine.

    I attached a log file.

     

    Last edit: June Liu 2022-06-28
  • CHR

    CHR - 2022-06-28

    Thanks for your detailed report, I can reproduce the issue. However, I'm not familiar with CMake, so I don't know what causes the problem.
    As a workaround, could you use the provided solution file?

     
    • June Liu

      June Liu - 2022-06-29

      Thanks for looking this issue. I tried the workaround you said, it works, thank you.

       

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.