Skip to content

MSC unreachable code warning because of if constexpr (..) #4810

Description

@torsten48

It looks like a new fmt version is comming soon (ChangeLog.md), so I testet the current main in my project and got annoying unreachable code warnings.
Example (fmt/base.h::2927)

template <typename... T>
FMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {
  vargs<T...> va = {{args...}};
  if FMT_CONSTEXPR20 (detail::use_utf8) return vprintln(f, fmt.str, va);
  detail::vprint_mojibake(f, fmt.str, va, true);
}

In my case, the compiler sees detail::vprint_mojibake(f, fmt.str, va, true); as dead (unreachable) code.

Would it be acceptable for you if I supply a pr to add else in such places to avoid the warning?

template <typename... T>
FMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {
  vargs<T...> va = {{args...}};
  if FMT_CONSTEXPR20 (detail::use_utf8) return vprintln(f, fmt.str, va);
    else detail::vprint_mojibake(f, fmt.str, va, true);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions