Skip to content

Clang mingw64 might somehow expands EXPECT_EQ as constexpr. I suspect that its result as "constexpr call consteval" #2223

Description

@denchat

It seems EXPECT_EQ somehow expand into constexpr calling test_format<> which is consteval, so it triggers errors.

Perhaps this might be a bug in mingw64 or clang, not fmtlib.
However, anyone has any workaround suggested?

C:\Users\User\AppData\Roaming\fmt>cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="C:/Program Files (x86)/Ninja/ninja.exe" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -DCMAKE_CXX_FLAGS="-fuse-ld=lld --target=x86_64-w64-windows-gnu --driver-mode=g++ -O3 -std=gnu++2b -static-libgcc -static-libstdc++ -fconstexpr-backtrace-limit=0 -lwinpthread -DFMT_COMPILE_TIME_CHECKS=0 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -Wno-unused-command-line-argument" -DCMAKE_CXX_LINK_EXECUTABLE="C:/Program Files/LLVM/bin/lld.exe" -DBUILD_SHARED_LIBS=YES -DFMT_INSTALL=NO -DFMT_DOC=NO -DFMT_TEST=YES "C:/Users/User/AppData/Roaming/fmt-master"
-- CMake version: 3.20.0
-- The CXX compiler identification is Clang 12.0.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Version: 7.1.3
-- Build type: Release
-- CXX_STANDARD: 23
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success
-- Performing Test FMT_HAS_VARIANT
-- Performing Test FMT_HAS_VARIANT - Success
-- Required features: cxx_variadic_templates
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Looking for _strtod_l
-- Looking for _strtod_l - found
-- Performing Test FMT_HAS_MBIG_OBJ
-- Performing Test FMT_HAS_MBIG_OBJ - Failed
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS - Success
-- FMT_PEDANTIC: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/User/AppData/Roaming/fmt

C:\Users\User\AppData\Roaming\fmt>ninja -j 2
[14/51] Building CXX object test/CMakeFiles/compile-test.dir/compile-test.cc.obj
FAILED: test/CMakeFiles/compile-test.dir/compile-test.cc.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -DFMT_LOCALE -DFMT_SHARED -DGTEST_HAS_STD_WSTRING=1 -DGTEST_LANG_CXX11=1 -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -IC:/Users/User/AppData/Roaming/fmt-master/include -isystem C:/Users/User/AppData/Roaming/fmt-master/test/gtest -isystem C:/Users/User/AppData/Roaming/fmt-master/test/gmock -isystem C:/Users/User/AppData/Roaming/fmt-master/test/. -fuse-ld=lld --target=x86_64-w64-windows-gnu --driver-mode=g++ -O3 -std=gnu++2b -static-libgcc -static-libstdc++ -fconstexpr-backtrace-limit=0 -lwinpthread -DFMT_COMPILE_TIME_CHECKS=0 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -Wno-unused-command-line-argument -O3 -DNDEBUG -fno-delete-null-pointer-checks -std=gnu++2b -MD -MT test/CMakeFiles/compile-test.dir/compile-test.cc.obj -MF test\CMakeFiles\compile-test.dir\compile-test.cc.obj.d -o test/CMakeFiles/compile-test.dir/compile-test.cc.obj -c C:/Users/User/AppData/Roaming/fmt-master/test/compile-test.cc
C:/Users/User/AppData/Roaming/fmt-master/test/compile-test.cc:342:22: error: call to consteval function 'test_format<6, char, bool, FMT_COMPILE_STRING>' is not a constant expression
  EXPECT_EQ("true ", test_format<6>(FMT_COMPILE("{:5}"), true));
                     ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:1566:36: note: initializer of 'left_padding_shifts' is unknown
  size_t left_padding = padding >> shifts[specs.align];
                                   ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:1790:10: note: in call to 'write_padded(&string.buffer._M_elems[0], specs, 4, 4, [=](reserve_iterator<char *> it) {
    return copy_str<char>(data, data + size, it);
})'
  return write_padded(out, specs, size, width,
         ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:2250:12: note: in call to 'write(&string.buffer._M_elems[0], {&"true"[0], 4}, specs)'
    out_ = detail::write(out_, s, specs);
           ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:2291:5: note: in call to '&af(ctx, specs)->write({&"true"[0], 4}, specs)'
    write(string_view(value ? "true" : "false"), specs_);
    ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:2323:5: note: in call to '&af(ctx, specs)->write(true)'
    write(value != 0);
    ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/core.h:1377:12: note: in call to '&af(ctx, specs)->operator()(true)'
    return vis(arg.value_.bool_value);
           ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:3531:12: note: in call to 'visit_format_arg(af(ctx, specs), detail::make_arg<fmt::basic_format_context<char *, char>>(val))'
    return visit_format_arg(af(ctx, specs),
           ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/compile.h:599:16: note: in call to '&compiled.fmt->format(true, ctx)'
    return fmt.format(arg, ctx);
               ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/compile.h:836:13: note: in call to '&compiled->format(&string.buffer._M_elems[0], true)'
  return cf.format(out, args...);
            ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/compile.h:907:12: note: in call to 'format_to(&string.buffer._M_elems[0], compiled, true)'
    return format_to(out, compiled, std::forward<Args>(args)...);
           ^
C:/Users/User/AppData/Roaming/fmt-master/test/compile-test.cc:335:3: note: in call to 'format_to(&string.buffer._M_elems[0], format, true)'
  fmt::format_to(string.buffer.data(), format, args...);
  ^
C:/Users/User/AppData/Roaming/fmt-master/test/compile-test.cc:342:22: note: in call to 'test_format({{}}, true)'
  EXPECT_EQ("true ", test_format<6>(FMT_COMPILE("{:5}"), true));
                     ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/format.h:979:31: note: declared here
  static constexpr const char left_padding_shifts[5] = {31, 31, 0, 1, 0};
                              ^

Activity

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