Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
denchat opened this issue Apr 9, 2021 · 5 comments

Comments

@denchat
Copy link
Contributor

denchat commented Apr 9, 2021

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};
                              ^
@vitaut
Copy link
Contributor

vitaut commented Apr 10, 2021

Do you have a godbolt repo? I tried to make one in https://compiler-explorer.com/z/aW9WPKjdj but it didn't give an error.

@denchat
Copy link
Contributor Author

denchat commented Apr 10, 2021

I have no idea either.
I suspect it might be a clang 12 bug on win32 somehow.
I will try r399163b (11.0.5) then will report back.
https://android.googlesource.com/platform/prebuilts/clang/host/windows-x86/+/refs/heads/master/

@denchat
Copy link
Contributor Author

denchat commented Apr 10, 2021

Even with gmock, clang on CE seems okey
https://compiler-explorer.com/z/98nTz5bs6

@denchat
Copy link
Contributor Author

denchat commented Apr 10, 2021

No luck!
Clang 11 seems to has problems on its own.

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 -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 11.0.5
-- 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
[6/51] Building CXX object CMakeFiles/fmt.dir/src/format.cc.obj
C:/Users/User/AppData/Roaming/fmt-master/src/format.cc:58:17: warning: 'dllexport' attribute ignored on explicit instantiation definition [-Wignored-attributes]
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
                ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/core.h:228:37: note: expanded from macro 'FMT_INSTANTIATION_DEF_API'
#  define FMT_INSTANTIATION_DEF_API FMT_API
                                    ^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/core.h:210:32: note: expanded from macro 'FMT_API'
#    define FMT_API __declspec(dllexport)
                               ^
1 warning generated.
[8/51] Linking CXX shared library bin\libfmt.dll
FAILED: bin/libfmt.dll libfmt.dll.a
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -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 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -Wno-unused-command-line-argument -O3 -DNDEBUG   -shared -o bin\libfmt.dll -Wl,--out-implib,libfmt.dll.a -Wl,--major-image-version,7,--minor-image-version,1 CMakeFiles/fmt.dir/src/format.cc.obj CMakeFiles/fmt.dir/src/os.cc.obj  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(eh_alloc.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(eh_personality.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(new_op.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(locale.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(locale_init.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(stdexcept.o)

lld-link: error: duplicate symbol: typeinfo name for std::runtime_error
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(stdexcept.o)

lld-link: error: duplicate symbol: typeinfo for std::runtime_error
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(stdexcept.o)

lld-link: error: duplicate symbol: typeinfo for std::runtime_error
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(functexcept.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(functexcept.o)

lld-link: error: duplicate symbol: typeinfo name for std::runtime_error
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(functexcept.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(eh_exception.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(vterminate.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(bad_alloc.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(guard.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(eh_aux_runtime.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(bad_array_new.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(bad_cast.o)

lld-link: error: duplicate symbol: typeinfo name for std::exception
>>> defined at CMakeFiles/fmt.dir/src/format.cc.obj
>>> defined at libstdc++.a(bad_typeid.o)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[9/51] Building CXX object test/CMakeFiles/args-test.dir/args-test.cc.obj
ninja: build stopped: subcommand failed.

So you may close this.
It is likely a platform's problem, not the fmtlib.

@vitaut
Copy link
Contributor

vitaut commented Apr 11, 2021

Closing then.

BTW this looks very weird too:

-- CXX_STANDARD: 23

@vitaut vitaut closed this as completed Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants