expected-lite icon indicating copy to clipboard operation
expected-lite copied to clipboard

C4702: unreachable code

Open hanusek opened this issue 4 months ago • 2 comments

Hello! I have a problem:

C:\builds\eprotect-platfrom\auth\client\include\nonstd\expected.hpp(2142) : error C2220: the following warning is treated as an error
C:\builds\eprotect-platfrom\auth\client\include\nonstd\expected.hpp(2142) : warning C4702: unreachable code

OS: Windows 2022 Visual Studio 2022 v17.5.0

https://conan.io/center/recipes/expected-lite?version=0.6.3

hanusek avatar Feb 27 '24 15:02 hanusek

Me too

subbota-a avatar Mar 21 '24 04:03 subbota-a

How does that work? That line is a comment, there is no code there: https://github.com/martinmoene/expected-lite/blob/v0.6.3/include/nonstd/expected.hpp#L2142 Is it any different in your build directory?

szaszm avatar Apr 23 '24 18:04 szaszm

Hello!

Repro:

#include "expected.hpp"

int main()
{
    nonstd::expected<int, int> ei = 0;
    return ei.value();
}

Compile using cl /O2 /W4 /WX main.cpp. expected-lite version is 0.6.3.

Output:

Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.cpp
C:\test\expected.hpp(1803) : error C2220: the following warning is treated as an error
C:\test\expected.hpp(1803) : warning C4702: unreachable code

np-c0mp1ete avatar May 22 '24 21:05 np-c0mp1ete