8000 8000
Skip to content

insert else branch to avoid unreachable code warning#4130

Merged
vitaut merged 1 commit intofmtlib:masterfrom
torsten48:master
Aug 28, 2024
Merged

insert else branch to avoid unreachable code warning#4130
vitaut merged 1 commit intofmtlib:masterfrom
torsten48:master

Conversation

@torsten48
Copy link
Copy Markdown
Contributor

at least MSC caused warning C4702: unreachable code

at least MSC caused warning C4702: unreachable code
Copy link
Copy Markdown
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
Copy Markdown
Contributor
vitaut commented Aug 28, 2024

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

@torsten48
Copy link
Copy Markdown
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
@vitaut
Copy link
Copy Markdown
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

0