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

spdlog v1.9.1 and clang 12.0.1 (libc++) compilation failure #2034

Closed
btmcg opened this issue Aug 6, 2021 · 1 comment · Fixed by #2037
Closed

spdlog v1.9.1 and clang 12.0.1 (libc++) compilation failure #2034

btmcg opened this issue Aug 6, 2021 · 1 comment · Fixed by #2037

Comments

@btmcg
Copy link

btmcg commented Aug 6, 2021

I cannot seem to compile any code that includes spdlog with clang 12.0.1.

#include <spdlog/spdlog.h>

int
main(int /*argc*/, char** /*argv*/)
{
    spdlog::info("Welcome to spdlog!");
    return 0;
}
/usr/bin/clang++ -std=c++20 -stdlib=libc++ -ggdb3 -pedantic-errors -Wall -Werror -Wextra -O0 -DSPDLOG_COMPILED_LIB -isystem/tmp/spdlog/1.9.1/include -c main.cpp
-o main.o
In file included from main.cpp:1:
In file included from /tmp/spdlog/1.9.1/include/spdlog/spdlog.h:12:
In file included from /tmp/spdlog/1.9.1/include/spdlog/common.h:7:
In file included from /tmp/spdlog/1.9.1/include/spdlog/details/null_mutex.h:6:
In file included from /usr/bin/../include/c++/v1/atomic:579:
In file included from /usr/bin/../include/c++/v1/__threading_support:15:
In file included from /usr/bin/../include/c++/v1/chrono:829:
/usr/bin/../include/c++/v1/type_traits:1688:66: error: call to consteval function 'fmt::basic_format_string<char>::basic_format_string<fmt::basic_string_view<char>, 0>' is no
t a constant expression
    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
                                                                 ^
/tmp/spdlog/1.9.1/include/spdlog/common.h:141:41: note: in instantiation of template class 'std::is_convertible<const fmt::basic_string_view<char> &, fmt::basic_format_string
<char>>' requested here
    : std::integral_constant<bool, std::is_convertible<const T &, fmt::format_string<>>::value || is_convertible_to_wformat_string<T>::value>
                                        ^
/tmp/spdlog/1.9.1/include/spdlog/logger.h:107:52: note: in instantiation of template class 'spdlog::is_convertible_to_basic_format_string<const fmt::basic_string_view<char> &
>' requested here
                                                  !is_convertible_to_basic_format_string<const T &>::value,
                                                   ^
/tmp/spdlog/1.9.1/include/spdlog/logger.h:109:10: note: while substituting prior template arguments into non-type template parameter [with T = fmt::basic_string_view<char>]
    void log(source_loc loc, level::level_enum lvl, const T &msg)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/spdlog/1.9.1/include/spdlog/logger.h:102:9: note: while substituting deduced template arguments into function template 'log' [with T = fmt::basic_string_view<char>, $1 =
 (no value)]
        log(loc, lvl, string_view_t{msg});
        ^
/usr/bin/../include/c++/v1/type_traits:1688:66: note: undefined constructor 'basic_format_string<fmt::basic_string_view<char>, 0>' cannot be used in a constant expression
    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
                                                                 ^
/tmp/spdlog/1.9.1/include/spdlog/fmt/bundled/core.h:2835:17: note: declared here
  FMT_CONSTEVAL basic_format_string(const S& s) : str_(s) {
In file included from main.cpp:1:
In file included from /tmp/spdlog/1.9.1/include/spdlog/spdlog.h:12:
In file included from /tmp/spdlog/1.9.1/include/spdlog/common.h:7:
In file included from /tmp/spdlog/1.9.1/include/spdlog/details/null_mutex.h:6:
In file included from /usr/bin/../include/c++/v1/atomic:579:
In file included from /usr/bin/../include/c++/v1/__threading_support:15:
In file included from /usr/bin/../include/c++/v1/chrono:829:
/usr/bin/../include/c++/v1/type_traits:1688:66: error: call to consteval function 'fmt::basic_format_string<char>::basic_format_string<char [19], 0>' is not a constant expression
    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
                                                                 ^
/tmp/spdlog/1.9.1/include/spdlog/common.h:141:41: note: in instantiation of template class 'std::is_convertible<char const (&)[19], fmt::basic_format_string<char>>' requested here
    : std::integral_constant<bool, std::is_convertible<const T &, fmt::format_string<>>::value || is_convertible_to_wformat_string<T>::value>
                                        ^
/tmp/spdlog/1.9.1/include/spdlog/logger.h:107:52: note: in instantiation of template class 'spdlog::is_convertible_to_basic_format_string<char const (&)[19]>' requested here
                                                  !is_convertible_to_basic_format_string<const T &>::value,
                                                   ^
/tmp/spdlog/1.9.1/include/spdlog/logger.h:109:10: note: while substituting prior template arguments into non-type template parameter [with T = char [19]]
    void log(source_loc loc, level::level_enum lvl, const T &msg)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/spdlog/1.9.1/include/spdlog/logger.h:95:9: note: while substituting deduced template arguments into function template 'log' [with T = char [19], $1 = (no value)]
        log(source_loc{}, lvl, msg);
        ^
/tmp/spdlog/1.9.1/include/spdlog/logger.h:246:9: note: in instantiation of function template specialization 'spdlog::logger::log<char [19]>' requested here
        log(level::info, msg);
        ^
/tmp/spdlog/1.9.1/include/spdlog/spdlog.h:255:27: note: in instantiation of function template specialization 'spdlog::logger::info<char [19]>' requested here
    default_logger_raw()->info(msg);
                          ^
main.cpp:7:13: note: in instantiation of function template specialization 'spdlog::info<char [19]>' requested here
    spdlog::info("Welcome to spdlog!");
            ^
/usr/bin/../include/c++/v1/type_traits:1688:66: note: undefined constructor 'basic_format_string<char [19], 0>' cannot be used in a constant expression
    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
                                                                 ^
/tmp/spdlog/1.9.1/include/spdlog/fmt/bundled/core.h:2835:17: note: declared here
  FMT_CONSTEVAL basic_format_string(const S& s) : str_(s) {
                ^
2 errors generated.

spdlog was built using the following cmake command

cmake \
        -DCMAKE_BUILD_TYPE:STRING=Release \
        -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++ \
        -DCMAKE_CXX_FLAGS:STRING="-stdlib=libc++ -rtlib=compiler-rt -fuse-ld=lld -lgcc_s" \
        -DCMAKE_INSTALL_PREFIX:PATH=/tmp/spdlog/1.9.1 \
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
        -DSPDLOG_BUILD_SHARED:BOOL=OFF \
        -S . -B _build

Any help would be appreciated. Thanks!

@gabime
Copy link
Owner

gabime commented Aug 6, 2021

seems like duplicate of #2023

@dkavolis dkavolis mentioned this issue Aug 9, 2021
gabime added a commit that referenced this issue Aug 9, 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

Successfully merging a pull request may close this issue.

2 participants