Skip to content

Fix compilation error in clang 13 in C++20 mode - ambiguous call to log function - #2011

Merged
gabime merged 1 commit into
gabime:v1.xfrom
sjanel:bugfix/fixclangcompilation
Jul 27, 2021
Merged

gabime merged 1 commit into
gabime:v1.xfrom
sjanel:bugfix/fixclangcompilation

Conversation

@sjanel

@sjanel sjanel commented Jul 23, 2021 •

Copy link
Copy Markdown
Contributor

To reproduce, you will need to install clang 13 development branch:

mkdir build
cmake -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Debug -DSPDLOG_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++-13 -DSPDLOG_BUILD_EXAMPLE=ON ..
make
...
spdlog/include/spdlog/logger.h:95:9: error: call to member function 'log' is ambiguous
        log(source_loc{}, lvl, msg);
        ^~~
spdlog/include/spdlog/logger.h:238:9: note: in instantiation of function template specialization 'spdlog::logger::log<char [38]>' requested here
        log(level::debug, msg);
        ^
spdlog/include/spdlog/spdlog.h:249:27: note: in instantiation of function template specialization 'spdlog::logger::debug<char [38]>' requested here
    default_logger_raw()->debug(msg);
                          ^
spdlog/example/example.cpp:43:13: note: in instantiation of function template specialization 'spdlog::debug<char [38]>' requested here
    spdlog::debug("This message should not be displayed!");
            ^
spdlog/include/spdlog/logger.h:100:10: note: candidate function [with T = char [38], $1 = 0]
    void log(source_loc loc, level::level_enum lvl, const T &msg)
         ^
spdlog/include/spdlog/logger.h:138:10: note: candidate function [with T = char [38], $1 = 0]
    void log(source_loc loc, level::level_enum lvl, const T &msg)
         ^

Not sure if this is an issue coming from clang 13 in C++20 mode - but the 2 enable_if in logger.h are anyway not complement to each other.

Issue appeared recently (in 1.9 version), it is compiling fine with v1.8.5

@sjanel sjanel changed the title Fix compilation error in clang 13 - ambiguous call to log function Fix compilation error in clang 13 in C++20 mode - ambiguous call to log function Jul 23, 2021
@sjanel
sjanel force-pushed the bugfix/fixclangcompilation branch from a1f8f12 to e5f8235 Compare July 23, 2021 14:45
@gabime

gabime commented Jul 23, 2021

Copy link
Copy Markdown
Owner

Thanks. seems to fail some of the windows tests . Please fix it.

@sjanel

sjanel commented Jul 23, 2021

Copy link
Copy Markdown
Contributor Author

Thanks. seems to fail some of the windows tests . Please fix it.

Yeah, I saw that. I will try to reproduce the build failed in my Windows machine this week-end and fix them.

@sjanel
sjanel marked this pull request as draft July 26, 2021 09:22
@sjanel

sjanel commented Jul 26, 2021 •

Copy link
Copy Markdown
Contributor Author

Build error occurs with -DSPDLOG_WCHAR_SUPPORT=ON (only in Windows)

@sjanel
sjanel force-pushed the bugfix/fixclangcompilation branch 2 times, most recently from 1564b02 to 5a8540a Compare July 26, 2021 10:32
@gabime

gabime commented Jul 26, 2021

Copy link
Copy Markdown
Owner

@sjanel I tried to fix the warning in this branch: https://github.com/gabime/spdlog/tree/pr-2011

Could you please check if it solves it (i dont have clang 13 installed) ?

@sjanel

sjanel commented Jul 27, 2021

Copy link
Copy Markdown
Contributor Author

@sjanel I tried to fix the warning in this branch: https://github.com/gabime/spdlog/tree/pr-2011

Could you please check if it solves it (i dont have clang 13 installed) ?

That fixes, thanks!

@sjanel sjanel closed this Jul 27, 2021
@sjanel sjanel reopened this Jul 27, 2021
@sjanel
sjanel force-pushed the bugfix/fixclangcompilation branch from 5a8540a to aecdfc6 Compare July 27, 2021 07:19
@sjanel
sjanel marked this pull request as ready for review July 27, 2021 08:07
@gabime
gabime merged commit 5b4c4f3 into gabime:v1.x Jul 27, 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 this pull request may close these issues.

2 participants