clangd std::string and const char[...] [closed]

1 day ago 4
ARTICLE AD BOX

I have problems with clangd where it is claiming that a comparison is not possible between std::string and const char [521].

// Image returns a std::string REQUIRE ( surface->image() == ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" ".........................\n" );

Here the error message:

Invalid operands to binary expression ('string' (aka 'basic_string<char>') and 'const char[521]') (clang)

Another example:

std::println("string size {}", sizeof(std::string));

In template: no matching constructor for initialization of 'basic_string_view' (clang)

The compile_commands.json is generated and registered in .clangd:

InlayHints: Enabled: false CompileFlags: CompilationDatabase: build

The miracle to me is; the compiler compiles everything fine. I am using clang++ and all tools in version 20.1.2. Is this a bug or am I missing some configs? The compile commands are based on the CMakeLists.txt:

... set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_compile_options(-stdlib=libc++ -mavx -march=native) add_link_options(-stdlib=libc++) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ...

Edit: Here an ls -l on /usr/lib/llvm-20/bin:

insgesamt 161844 -rwxr-xr-x 1 root root 27312 Aug 14 16:59 amdgpu-arch -rwxr-xr-x 1 root root 557 Apr 2 2025 analyze-build -rwxr-xr-x 1 root root 378832 Aug 14 16:59 bugpoint -rwxr-xr-x 1 root root 34669672 Aug 14 16:59 c-index-test -rwxr-xr-x 1 root root 132448 Aug 14 16:59 clang lrwxrwxrwx 1 root root 5 Aug 14 16:59 clang++ -> clang lrwxrwxrwx 1 root root 5 Aug 14 16:59 clang-20 -> clang -rwxr-xr-x 1 root root 109680 Aug 14 16:59 clang-apply-replacements -rwxr-xr-x 1 root root 257656 Aug 14 16:59 clang-change-namespace -rwxr-xr-x 1 root root 56912 Aug 14 16:59 clang-check lrwxrwxrwx 1 root root 5 Aug 14 16:59 clang-cl -> clang lrwxrwxrwx 1 root root 5 Aug 14 16:59 clang-cpp -> clang -rwxr-xr-x 1 root root 17088008 Aug 14 16:59 clangd -rwxr-xr-x 1 root root 758144 Aug 14 16:59 clang-doc
Read Entire Article