Giter Site home page Giter Site logo

Build failure with OSX 13 about mpd HOT 4 CLOSED

jprjr avatar jprjr commented on June 12, 2024
Build failure with OSX 13

from mpd.

Comments (4)

MaxKellermann avatar MaxKellermann commented on June 12, 2024

What code location does it complain about?

from mpd.

jprjr avatar jprjr commented on June 12, 2024

from mpd.

MaxKellermann avatar MaxKellermann commented on June 12, 2024

I don't see where the code asks the compiler to convert a string_view to a string - do you?

from mpd.

jprjr avatar jprjr commented on June 12, 2024

I'm suspecting this may have to do with the clang version and that mine was a few versions old.

I went ahead and downloaded the latest xcode command-line tools and installed, and the error went away.

Using clang/llvm version 12 though, I do get the error - and wth clang/llvm version 13, I don't.

Using this minimal example:

#include <string>
#include <set>
#include <string_view>

bool SetContains(const std::set<std::string, std::less<>> &set, const std::string_view &key) {

    return set.contains(key);
}

Using clang-12:

% /usr/local/opt/llvm@12/bin/clang++  -std=c++20 -c test.cpp
test.cpp:7:25: error: no viable conversion from 'const std::string_view' (aka 'const basic_string_view<char>') to 'const std::set<std::string, std::less<>>::key_type' (aka 'const std::string')
    return set.contains(key);
                        ^~~
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:821:5: note: candidate constructor not viable: no known conversion from 'const std::string_view' (aka 'const basic_string_view<char>') to 'const std::string &' for 1st argument
    basic_string(const basic_string& __str);
    ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:826:5: note: candidate constructor not viable: no known conversion from 'const std::string_view' (aka 'const basic_string_view<char>') to 'std::string &&' for 1st argument
    basic_string(basic_string&& __str)
    ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:839:5: note: candidate constructor template not viable: no known conversion from 'const std::string_view' (aka 'const basic_string_view<char>') to 'const char *' for 1st argument
    basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
    ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:890:5: note: candidate constructor not viable: no known conversion from 'const std::string_view' (aka 'const basic_string_view<char>') to 'initializer_list<char>' for 1st argument
    basic_string(initializer_list<_CharT> __il);
    ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:814:40: note: explicit constructor is not a candidate
    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
                                       ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/string:876:18: note: explicit constructor is not a candidate
        explicit basic_string(const _Tp& __t);
                 ^
/usr/local/opt/llvm@12/bin/../include/c++/v1/set:797:35: note: passing argument to parameter '__k' here
    bool contains(const key_type& __k) const {return find(__k) != end();}
                                  ^
1 error generated.

My guess is the following is occurring, though I now wonder if this is a compiler bug?

So here:

std::set<std::string, std::less<>> (*suffixes_function)() noexcept = nullptr;

The function suffixes_function() is declared to return std::set<std::string, std::less<>>

Then here:

SetContains(const auto &set, const auto &key) noexcept

SetContains is declared as a function that accept (const auto &set, const auto &key)

Looking at

DecoderPlugin::SupportsSuffix(std::string_view suffix) const noexcept

since the suffix parameter is a string_view, and the suffixes_function returns a std::set<std::string, std::less<>>, the call to SetContains is essentially now SetContains(const std::set<std::string, std::less<>> &set, const std::string_view &key)

And apparently this out-of-date clang version I had considers that an error.

I'm guessing this can be closed since the fix is to just update to a newer clang, sorry for the noise.

from mpd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.