Incorrect error for static_cast

I have a struct defined as follows:

struct Cursor {
uint64_t value;

Cursor()
: value(0) {
}

explicit Cursor(uint64_t value)
: value(value) {
}

operator uint64_t() const {
return value;
}
}


CLion reports an error for the line with static_cast in:

typedef int jint;
static inline Cursor managedToNativeCursor(jint value) {
return static_cast<Cursor>(value);
}
"Expression of type 'jint' cannot be cast to type 'Cursor': Types 'Cursor' and 'jint' are not compatible"

While the g++ successfully compiles this line.

1 comment
Comment actions Permalink

Hi Dmitry!

We have related issue in our tracker, I've added your example. Feel free to comment or upvote.

0

Please sign in to leave a comment.