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

[clangd-11] Consistent-comparison + designated initialisers = crash #383

Closed
cjdb opened this issue May 10, 2020 · 0 comments
Closed

[clangd-11] Consistent-comparison + designated initialisers = crash #383

cjdb opened this issue May 10, 2020 · 0 comments

Comments

@cjdb
Copy link

cjdb commented May 10, 2020

Given a compile_commands.json with

{
  "directory": "/home/christopher/projects/wl/build-Release",
  "command": "/usr/bin/clang++-11   -I../include -I../   -fvisibility=hidden -fstack-protector -fdiagnostics-color=always -pedantic -Werror -Wall -Wextra -Wcast-align -Wconversion -Wdouble-promotion -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wshadow -Wsign-conversion -Wsign-promo -Wunused -Wformat=2 -Wodr -Wno-attributes -Wnull-dereference -Wno-unused-command-line-argument -stdlib=libc++ -O3 -DNDEBUG -fsanitize=cfi -flto=thin   -std=c++2a -o CMakeFiles/demo.dir/demo.cpp.o -c /home/christopher/projects/wl/demo.cpp",
  "file": "/home/christopher/projects/wl/demo.cpp"
},

This program crashes clangd-11.

struct s {
	int x;
	friend auto operator==(s a, s b) -> bool = default;
};

auto main() -> int {
	auto a = s{.x = 0};
	auto b = s{.x = 1};
	return a != b;
}

It seems to be the combination of generating operator== and operator!= as friends (members are okay), using the one of the generated operators, and also using designated initialisers. Remove any of the three from the piece, and the crash isn't triggered.

Logs
Please attach the clangd stderr log if you can. (Usually available from the editor)
If possible, run with --log=verbose - note that the logs will include the contents of open files!
If this is a crash, try to put llvm-symbolizer on your PATH per the troubleshooting instructions.

clangd-output.txt

System information
Output of clangd --version: clangd version 11.0.0-++20200510052610+bcc5ed7b24e-1~exp1~20200510153213.37
Editor/LSP plugin: VS Code
Operating system: WSL Ubuntu20.04

arichardson pushed a commit to arichardson/llvm-project that referenced this issue Jul 3, 2020
…C++20.

Summary:
Make RAV not visit the default function decl by default.
Also update some stale comments on FunctionDecl::isDefault.

Fixes clangd/clangd#383

Reviewers: sammccall, rsmith

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80288
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

1 participant