[MSVC] Bitcoin failed to build with waring c4858 on MSVC #26017

issue fangzhouxia opened this issue on September 6, 2022
  1. fangzhouxia commented at 7:42 AM on September 6, 2022: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

    <!-- Describe the issue -->

    Describe Hi all, Bitcoin fails to build on MSVC due to waring c4858. Could you help look? Expected behavior Build successfully.

    <!--- What behavior did you expect? -->

    Actual behavior F:\gitP\bitcoin\bitcoin\src\sync.h(168): error C2220: the following warning is treated as an error F:\gitP\bitcoin\bitcoin\src\sync.h(166): note: while compiling class template member function 'bool UniqueLock<_Ty,std::unique_lock<PARENT>>::TryEnter(const char *,const char *,int)' with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\sync.h(179): note: see reference to function template instantiation 'bool UniqueLock<_Ty,std::unique_lock<PARENT>>::TryEnter(const char *,const char *,int)' being compiled with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\net.h(822): note: see reference to class template instantiation 'UniqueLock<_Ty,std::unique_lock<PARENT>>' being compiled with [ _Ty=RecursiveMutex, PARENT=std::recursive_mutex ] F:\gitP\bitcoin\bitcoin\src\sync.h(168): warning C4858: discarding return value: This function returns whether the operation succeeded in modifying object state. It is dangerous to ignore the return value. Detail log Uploading build (3).log…

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    To reproduce

    1. git clone https://github.com/bitcoin/bitcoin F:\gitP\bitcoin\bitcoin
    2. cd F:\gitP\bitcoin\bitcoin\build_msvc
    3. py -3 msvc-autogen.py
    4. cd F:\gitP\bitcoin\tools\vcpkg
    5. git -C "F:\gitP\bitcoin\tools\vcpkg" clean -xdf 2>&1
    6. bootstrap-vcpkg.bat 2>&1
    7. set path=%cd%;%path%
    8. cd F:\gitP\bitcoin\bitcoin\build_msvc
    9. msbuild /m /p:Platform=x64 /p:Configuration=Release bitcoin.sln /t:Rebuild 2>&1

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    System information VS version: VS2019 (16.11.11) Operating system: windows server 2019 the commit of Bitcoin we use is 5174a13

    workaround I modified the common.init.vcxproj.in file of this text like below to solve this issue: <DisableSpecificWarnings>4018;4244;4267;4334;4715;4805;4834</DisableSpecificWarnings> to be: <DisableSpecificWarnings>4018;4244;4267;4334;4715;4805;4834;4858</DisableSpecificWarnings>

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    <!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

  2. fangzhouxia added the label Bug on Sep 6, 2022
  3. fanquake added the label Windows on Sep 6, 2022
  4. fanquake commented at 7:48 AM on September 6, 2022: member
  5. fangzhouxia commented at 10:03 AM on September 6, 2022: none

    This is an internal test of MSVC, using the latest compiler

  6. maflcko removed the label Bug on Sep 6, 2022
  7. maflcko added the label Tests on Sep 6, 2022
  8. maflcko commented at 10:09 AM on September 6, 2022: member

    This is an internal test of MSVC, using the latest compiler

    Which version? In any case, bugs in internal tests against msvc should likely be reported to microsoft.

  9. hebasto commented at 10:16 AM on September 6, 2022: member

    F:\gitP\bitcoin\bitcoin\src\sync.h(168): warning C4858: discarding return value: This function returns whether the operation succeeded in modifying object state. It is dangerous to ignore the return value.

    Microsoft's docs do not mention "C4858", but "C4834", which is fixed in #25819.

  10. fangzhouxia commented at 1:56 AM on September 7, 2022: none

    Which version? In any case, bugs in internal tests against msvc should likely be reported to microsoft.

    The version used is as follows: Screenshot 2022-09-07 095124

  11. fangzhouxia commented at 8:06 AM on September 7, 2022: none
  12. fangzhouxia commented at 7:20 AM on September 13, 2022: none

    Thank you, I use the method you provided, it is ok.

  13. fanquake closed this on Sep 13, 2022

  14. fanquake referenced this in commit 1730f6cb23 on Oct 3, 2022
  15. sidhujag referenced this in commit 861db05f8b on Oct 4, 2022
  16. hebasto removed the label Tests on Oct 20, 2022
  17. bitcoin locked this on Oct 20, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me