Clion 2021.2.2 no longer recognises C++20 concepts syntax

已完成

Since updating from Clion 2021.1.3 to Clion 2021.2, I've been getting errors with certain C++20 features in my projects. Here is a small project that reproduces the problem for me. Hopefully it's just a configuration issue on my part and not a CLion bug, but any help would be greatly appreciated!

Steps to reproduce:

Create a new C++ Executable project with C++20 support selected.

Copy and paste, replacing the contents of main.cpp, with the first example from https://en.cppreference.com/w/cpp/language/constraints

#include <string>
#include <cstddef>
#include <concepts>
 
// Declaration of the concept "Hashable", which is satisfied by any type 'T'
// such that for values 'a' of type 'T', the expression std::hash<T>{}(a)
// compiles and its result is convertible to std::size_t
template<typename T>
concept Hashable = requires(T a) {
    { std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
};
 
struct meow {};
 
// Constrained C++20 function template:
template<Hashable T>
void f(T) {}
//
// Alternative ways to apply the same constraint:
// template<typename T>
//    requires Hashable<T>
// void f(T) {}
//
// template<typename T>
// void f(T) requires Hashable<T> {}
 
int main() {
  using std::operator""s;
  f("abc"s); // OK, std::string satisfies Hashable
//f(meow{}); // Error: meow does not satisfy Hashable
}

Observe the following errors even though the project compiles correctly:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(cpp20testproj)

set(CMAKE_CXX_STANDARD 20)

add_executable(cpp20testproj main.cpp)

Version information:

CLion 2021.2.2
Build #CL-212.5284.51, built on September 16, 2021
Runtime version: 11.0.12+7-b1504.28 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 10000M
Cores: 12
Registry: debugger.watches.in.variables=false, run.processes.with.pty=true
Non-Bundled Plugins: com.jetbrains.plugins.ini4idea (212.4746.57), com.markskelton.one-dark-theme (5.3.1), com.intellij.plugins.watcher (212.5080.8)
0

Hello!

What toolchain do you use? Please attach a screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).

0

Hi Anna, thank you for taking the time to help me with this!

0

So far we didn't manage to reproduce the issue on our side.

Please create an issue in our tracker (https://youtrack.jetbrains.com/issues/CPP) and attach the following materials:

  1. Do Help | Collect Logs and Diagnostic Data and attach the resulted archive. Note that logs might contain private user's information (like file paths and names).
  2. Please make sure the editor with the main.cpp file is focused, do Help | Find Action > Show Compiler Info and attach the result.

You can attach the materials privately (with visibility to CLion team), the instruction is here.

0

Ok, I've submitted an issue with the requested information: https://youtrack.jetbrains.com/issue/CPP-26991

0

请先登录再写评论。