CLion seems to not recognize operator overloading


I have a problem with CLion's C++ code inspection.

There is my main function :

#include <iostream>
#include <string>

using namespace std;

int main()
  string s1 ("Hello World!");
s2 ("Test");
s3 = s1 + s2;

  if (s1 == s2)
    cout << "No !" << endl;
cout << s3 << endl;

CLion underlines the section "s1 + s2" in red and says "binary operator '+' can't be applied to the expression of type 'string' and 'string'", and the section "s1 == s2", saying "Can't compare structures", but the code is compiling.

There is my CMakeLists.txt :

cmake_minimum_required(VERSION 3.3)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")

set(SOURCE_FILES main.cpp)
add_executable(Test2 ${SOURCE_FILES})

When I turn on c++11, the error on "s1 == s2" disapear, but not the error on "s1 + s2".

I am using CLion 1.2.4 build #CL-143.1186

Thank you.

Comment actions Permalink

Hi Hugo.

This example correctly works in my environment. Could you please attach a screenshot with Toolchains tab (Settings (Preferences) | Build, Execution, Deployment | Toolchains)?

Comment actions Permalink

Thanks for your response.

There is the toolchains window

Comment actions Permalink

i have the same problem. When i compile everything works fine.

In the previous version of clion i hadn't this problem.

Comment actions Permalink


Thanks, we have found the problem. Please upvote the issue in our tracker:

Comment actions Permalink

I have similar issue, CLion doesn't recognize overloading of operator = for std::pair:




Comment actions Permalink

@Vasyl, here is the related issue: Feel free to comment or upvote, follow it to get updates.


Please sign in to leave a comment.