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

Workaround for GCC -Wduplicated-branches #573

Closed
VaderDev opened this issue Sep 28, 2017 · 1 comment
Closed

Workaround for GCC -Wduplicated-branches #573

VaderDev opened this issue Sep 28, 2017 · 1 comment

Comments

@VaderDev
Copy link

VaderDev commented Sep 28, 2017

Hi,

The following line triggers the following GCC 7.1 -Wduplicated-branches warning:

fmt/fmt/format.h

Line 2326 in 2a619d9

typedef Value Type[N > 0 ? N : 1];

fmt/include/fmt/format.h: In instantiation of 'struct fmt::internal::ArgArray<1, true>':
fmt/include/fmt/format.h:3467:1: required from 'std::__cxx11::string fmt::format(fmt::CStringRef, const Args& ...) [with Args = {unsigned int, char [5]}; std::__cxx11::string = std::__cxx11::basic_string<char>; fmt::CStringRef = fmt::BasicCStringRef<char>]'
cc1plus: warning: this condition has identical branches [-Wduplicated-branches]

I am pretty sure this is a false positive scenario for this warning (partial evaluation of compile time expression for this warning doesn't seams right), workaround could be:

static constexpr size_t shut_up_gcc = N;
typedef Value Type[N > 0 ? shut_up_gcc : 1];
// or just:
typedef Value Type[N > 0 ? N + 0 : 1];

I will file a gcc issue for this behavior (and also for the fact that I am including fmt as system headers so I should not get any warnings). My head hurts and I am sorry that I even raised this issue.

@vitaut
Copy link
Contributor

vitaut commented Sep 28, 2017

Fixed in bef89db, thanks for reporting!

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

No branches or pull requests

2 participants