Dariusz
Dariusz

Reputation: 1054

cLion & cMake not debugning/printing an error

I have a weird issue that I just learned about. If I run this code in Visual Studio I get output that is NULL/error. But when I run in cLion I just get app crash and no feedback.

VS error :

Exception thrown: read access violation.
this was nullptr.

Here is my config:

main.cpp

#include <iostream>

using namespace std;

class testNothing {
public:
    testNothing *test;
    void donothing() { cout << test << endl; };
};

int main()
{
    testNothing *hey = nullptr;

    hey->donothing();

    return 1;
};

CMakeList.txt

cmake_minimum_required(VERSION 3.8)
project(tests)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

Upvotes: 0

Views: 1433

Answers (1)

Saurabh Shrivastava
Saurabh Shrivastava

Reputation: 1113

To receive feedback, you may run your project in 'Debug' mode.

You may go to Run > Debug from menu bar, or simply press the 'bug' icon on the top left corner to enter debug mode.

Output in debug mode : EXC_BAD_ACCESS (code=1, address=0x0).

You'll also get complete interactive stack trace of the same.

Upvotes: 1

Related Questions