gcc 10.1: weird behavior with clang-tidy (clion) and precompiled headers (cmake)

蓝咒 提交于 2021-02-05 10:26:35

问题


I have had problems with my IDE since an update to GCC 10.1 a few days ago. I use CLion, which uses clang-tidy as linter. I also use the newly introduced command target_precompiled_headers from CMake to use PCH for my project. Unfortunately I get weird linter warning and error messages:

That's how I include the header file for my pch in my CMakeLists.txt:

target_precompile_headers(Peach PRIVATE ${PROJECT_SOURCE_DIR}/Src/peach_pch.h)

Strangely enough, my program compiles perfectly. So the error messages must (obviously) be wrong. This is very irritating for me and my development process. With GCC 9 I did not have these problems. Unfortunately I have no possibility to downgrade at the moment. Also with Clang 10 the same problem occurs. Without PCH the error messages do not appear. But I do not want to work without it.

I've already done a lot of research. There is an open bug for clang: bugs.llvm.org. But I really don't know whether this is the problem or something else. It is hard to find out if the error is in CLion, GCC, Clang or something else. I only observed that with GCC 10.1 the error occurred for the first time.

Maybe someone has an idea or at least the same issue.

EDIT:

I kinda solved the issue by myself. I used the C++20 standard within my CMakeLists.txt:

set(CMAKE_CXX_STANDARD 20)

When I switch to C++17 the "error" messages disappeared. I had the guess, that there are some overlaps in the std lib since std::ranges (the error from the picture) exists since C++20.

So I think it could be a bug in the latest version of GCC?

来源:https://stackoverflow.com/questions/61941032/gcc-10-1-weird-behavior-with-clang-tidy-clion-and-precompiled-headers-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!