Skip to content

‘args#0’ is not a constant expression under c++20 #154

@hsgui

Description

@hsgui

in flare/base/tsc.h

inline std::uint64_t TscElapsed(std::uint64_t start, std::uint64_t to) {
  if (FLARE_UNLIKELY(start >= to)) {
    FLARE_LOG_WARNING_IF_EVERY_N(
        start - to > 1'000'000, 100,
        "Unexpected: TSC goes backward for more than 1M cycles (0.5ms on "
        "2GHz). You will likely see some unreasonable timestamps. Called with "
        "start = {}, to = {}.",
        start, to);
    return 0;
  }
  return to - start;
}

when the code calls into the following code:

template <class... Ts>
std::string FormatLog([[maybe_unused]] const char* file,
                      [[maybe_unused]] int line, const Ts&... args) noexcept {
  std::string result;

  WritePrefixTo(&result);
  if constexpr (sizeof...(Ts) != 0) {
    try {
      result += fmt::format(args...);
    } catch (const std::exception& xcpt) {
      // Presumably a wrong format string was provided?
      LOG(FATAL) << "Failed to format log at [" << file << ":" << line
                 << "]: " << xcpt.what();
    }
  }
  return result;
}

there is a compiling issue:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions