Any chance to inspect VLAs in CLion debug?

已回答

It seems to me that variable-length arrays cannot be inspected in variable view at debugging time. Any idea?

0

Hello!

What debugger do you use, LLDB or GDB? Also please provide a simple code sample and a screenshot of results in the Variables tab. Thanks!

0
Avatar
Permanently deleted user

Hi, Anna!

I use Bundled LLDB version 6.0.1, Xcode 10.1, CLion 2018.3.4 on macOS 10.14.3.

A sample code is as follows:

#include <iostream>
using namespace std;

constexpr int MAX_N = 100;

int main() {
int n;
cin >> n;
int arr[n];
// int arr[MAX_N]; Of course this is OK!
for (int i{}; i < n; ++i) {
cin >> arr[i];
}

for (const auto& v : arr) {
cout << v << endl;
}

return 0;
}

This is the screenshot just after I pushed the right side drop down icon of the arr variable.



Thanks!

0

Tatsuhiko, thank you for the response! Feel free to comment or upvote a related issue in our tracker in order to get updates: https://youtrack.jetbrains.com/issue/CPP-6491.

1

The only workaround I can come up with is to add an expression similar to ((int (*)[5])arr) to Watches:

1

请先登录再写评论。