CLion not honoring C++ version

Hello, this is something I noticed the other day while checking some stuff with my coworkers.

CLion does not honor for some reason the C++17 convention that dictates order of evaluation while Rider does.

The most easy to reproduce example is this:

#include <iostream>

int main() {
int i = 0;
std::cout << i << ++i << std::endl;
return 0;
}

This should produce 11 output since C++17 since the evaluation order has been defined for cout lines.

Now with CLion it outputs 01 while on Rider and Visual Studio it outputs the expected 11 (being evaluated right to left).

I attempted to enforce the minimum C++ version using various approaches on the cmake configs with no avail, if someone figures this out, ill be glad to know how.

This is the cmake for this particular example since is the most simple and easy to reproduce one.

cmake_minimum_required(VERSION 3.24)
project(CPP17Test)

set(CMAKE_CXX_STANDARD 17)

add_executable(CPP17Test main.cpp)
target_compile_features(CPP17Test PUBLIC cxx_std_17)
cmake_minimum_required(VERSION 3.24)
project(CPP17Test)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(CPP17Test main.cpp)

Neither of those work. Is something I'm missing?

I am using the following toolchain configurations:

And the following cmake ones.

 

If someone knows how to fix this and can explain me the process to get said information, I'll be eternally grateful.

0

Please sign in to leave a comment.