Skip to content

[Bug]: PrintTo(char8_t), PrintTo(char16_t) behave incorrectly #4762

Open
@cor3ntin

Description

@cor3ntin

Describe the issue

charN_t are cast to char32_t before being displayed using the U+xxxx notation.
This is incorrect for values that do not represent valid codepoints, such as lone surrogates, char8_t values outside the basic Latin1 range, etc.

This was found by a Clang warning to detect incorrect conversions between charN_t that we are rolling out,

Steps to reproduce the problem

https://compiler-explorer.com/z/xE56jbK5M

#include <gtest/gtest-printers.h>
#include <iostream>

int main() {
    testing::internal::PrintTo(char8_t(0x80), 
                                                 &std::cout);
}

What version of GoogleTest are you using?

trunk

What operating system and version are you using?

What compiler and version are you using?

clang trunk

What build system are you using?

Additional context

No response

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