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

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

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

    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>::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>::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>’ 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…

    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

    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>

  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: 2024-09-29 01:12 UTC

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