Skip to content

[Bug]: clang-21 build error: gtest-printers.h:528:35: error: implicit conversion from 'char8_t' to... #4948

@dokastho

Description

@dokastho

Describe the issue

/opt/homebrew/include/gtest/gtest-printers.h:528:35: error: implicit conversion from 'char8_t' to 'char32_t' may change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
  528 |   PrintTo(ImplicitCast_<char32_t>(c), os);
      |           ~~~~~~~~~~~~~           ^
1 error generated.

Latest brew version of gtest does not build with clang 21 on macOS Tahoe:

$ clang --version
Apple clang version 21.0.0 (clang-2100.3.6.4)

Proposed fix:

static cast to the expected type:

replace line 528 with

PrintTo(static_cast<char32_t>(static_cast<unsigned char>(c)), os);

Steps to reproduce the problem

#include "gtest/gtest.h" in any c++ source file with CXX standard 20

What version of GoogleTest are you using?

$ brew info googletest
==> googletest ✔: stable 1.17.0 (bottled), HEAD

What operating system and version are you using?

macOS Tahoe 26.4, build version 25E246

What compiler and version are you using?

$ clang --version
Apple clang version 21.0.0 (clang-2100.3.6.4)

What build system are you using?

$ cmake --version
cmake version 4.3.1

Additional context

Thank you.

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