Project

General

Profile

Actions

Emulator Issues #12468

closed

Dolphin failed to build due to "error C2131: expression did not evaluate to a constant" with MSVC on windows

Added by QuellaZhang over 3 years ago. Updated over 3 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:
5.0-13999

Description

Hi All,

Environment:
VS 2019 + Windows Server 2016 + dolphin master branch latest source code.

Dolphin failed to build due to 'error C2131: expression did not evaluate to a constant' with MSVC on windows. It can be reproduced on latest commit 9d0983c. Could you please help take a look at this issue? Thanks in advance! This issue will be triggered on the upcoming version of MSVC.

Repro steps:

  1. git clone https://github.com/dolphin-emu/dolphin.git F:\gitP\dolphin-emu\dolphin
  2. git submodule init
  3. git submodule update --recursive
  4. Open a VS 2019 x64 command prompt and browse to F:\gitP\dolphin-emu\dolphin\Source
  5. set CL=/D_HAS_DEPRECATED_RESULT_OF=1 /D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING /wd5054
  6. msbuild /m /p:Platform=x64 /p:Configuration=Release /p:WindowsTargetPlatformVersion=10.0.19041.0 dolphin-emu.sln /t:Dolphin

Actual result:
F:\gitP\dolphin-emu\dolphin\Source\Core\Core\WiiUtils.cpp(112,96): error C2131: expression did not evaluate to a constant
for (const std::string& path : {"/shared2/ec/shopsetu.log", "/shared2/succession/shop.log"})
^
F:\gitP\dolphin-emu\dolphin\Source\Core\Core\WiiUtils.cpp(112,96): note: (sub-)object points to memory which was deallocated during constant evaluation
for (const std::string& path : {"/shared2/ec/shopsetu.log", "/shared2/succession/shop.log"})
^
F:\gitP\dolphin-emu\dolphin\Source\Core\Core\WiiUtils.cpp(131,4): note: while evaluating constexpr function 'WiiUtils::ImportWAD::<lambda_5>::operator ()'
}();
^


Files

build.log (223 KB) build.log QuellaZhang, 03/31/2021 09:37 AM
Actions #1

Updated by Dentomologist over 3 years ago

I can't reproduce this, but from the error message it looks like you can fix the problem by removing the '&' from line 112 of Source\Core\Core\WiiUtils.cpp to make it match the following:

for (const std::string path : {"/shared2/ec/shopsetu.log", "/shared2/succession/shop.log"})

Let me know if that works and if so I'll make a PR for it.

Actions #2

Updated by QuellaZhang over 3 years ago

Thanks. I tried the fix and it worked.

Actions #3

Updated by JosJuice over 3 years ago

  • Status changed from New to Fixed
  • Fixed in set to 5.0-13999
Actions

Also available in: Atom PDF