Skip to content

Commit removing a clang-tidy false positive also introduces one #4871

Closed

Description

@jefftrull

The following simple program:

#include <fmt/compile.h>

#include <iostream>

int main() {
    constexpr auto fmtstr = FMT_COMPILE(std::string_view("Hello {}"));
    constexpr auto a = 42;
    constexpr auto sz = fmt::formatted_size(fmtstr, a);

    std::cout << sz << "\n";
}

when run under clang-tidy (v19) gives the following error message:

error: constexpr variable 'sz' must be initialized by a constant expression [clang-diagnostic-error]

when compiled with clang++ there are no errors.

Reverting this fmt commit ("Suppress a false positive in clang-tidy") causes the clang-tidy error to go away.

Is it possible this change needs tweaking?

Activity

  1. vitaut commented on Aug 2, 2026

    @vitaut
    Contributor

    I think we should just revert that change. A PR is welcome.

  2. jefftrull commented on Aug 2, 2026

    @jefftrull
    Author

    What about the original false positive?

  3. vitaut commented on Aug 3, 2026

    @vitaut
    Contributor

    I don't think it matters and I don't have a repro but if anyone is interested they can add a more narrow workaround later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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