Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert else branch to avoid unreachable code warning #4130

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

torsten48
Copy link
Contributor

at least MSC caused warning C4702: unreachable code

at least MSC caused warning C4702: unreachable code
Copy link
Contributor

@sunmy2019 sunmy2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vitaut
Copy link
Contributor

vitaut commented Aug 28, 2024

Thanks for the PR but could you provide a godbolt repro demonstrating the issue?

@torsten48
Copy link
Contributor Author

Godbolt seems to currently have a problem using MSC and fmt:
https://godbolt.org/z/x638qzfc9

but here is my max reduced example:

test.cpp
`#pragma warning(3:4702)

#define FMT_HEADER_ONLY
#define FMT_UNICODE 0

#include "fmt/format.h"
#include "fmt/compile.h"

int main()
{
fmt::print(FMT_COMPILE("The answer is {}."), "42");
return 0;
}`

MSC (VS 17.11.1)
`C:\build\tt>cl /W3 /std:c++20 /EHsc test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34120 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

test.cpp
C:\build\tt\fmt\base.h(2162): warning C4267: '=': conversion from 'size_t' to 'unsigned long', possible loss of data
C:\build\tt\fmt\compile.h(147) : warning C4702: unreachable code
Microsoft (R) Incremental Linker Version 14.41.34120.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:test.exe
test.obj`

Notice the string "42"!

@vitaut vitaut merged commit bbf8b3b into fmtlib:master Aug 28, 2024
43 checks passed
@vitaut
Copy link
Contributor

vitaut commented Aug 28, 2024

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants