When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
55 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
Se comment in code about IDE saying this if statement is always false
like that's not true...right?
what if statement?
I doubt your IDE would be incorrect. In general the IDE is always correct when it comes to such warnings.
how? That's impossible
Do you still have the code that was giving that warning?
Yes
It still gives the warning, I need to adjust clion to like turn of static analysis for that function
Let me show you
mind if you share?
Yeah, try posting it in your ide and see
template <typename T>
void Heap<T>::maxHeapify(int i) {
int left = getLeft(i);
int right = getRight(i);
int largest;
if(left <= values.size() && values[left] > values[i])
{
largest = left;
} else {
largest = i;
}
if(right <= values.size() && values[right] > values[largest])
{
largest = right;
}
if(largest != i)
{
// T temp = values[largest];
// values[largest] = values[i];
// values[i] = temp;
//cpp way
std::swap(values[largest], values[i]);
maxHeapify(largest);
}
}
cpp btw
last if statement
Can't copy it into an IDE without rebooting to Linux
so, if (largest != i) is always false according to your IDE
So largest == i is apparently always true
okay, lemme follow the control flow
Logically it makes 0 sense lol
regardless of what getRight and getLeft return
values can be a vector in any order
What does getLeft return?
getLeft = i << 1
getRight = i << 1 + 1
I'm telling you
it is a static analysis bug
I've ran the code through a unit test
I am too lazy to report it to clion / jetbrains
hmm, okay. Very weird
For instance, Visual Studio 2022
doesn't say this
only clion
so, if that means anything
Damn, okay. Sorry for not believing you, but you have to admit, whout providing some code this does sound kinda sus
Yeah, I have like 100 files of cpp code in my game engine project
never once have I seen anything like this
especially for such a simple function
I'm more a beginner than I am an intermediate I'd say
or at least I wouldn't feel comfortable advertising myself as an intermediate
Oh ok fair enough, same here
Because otherwise I'd have to use a VM and/or WSL, which is what I have to do on my horrendously old laptop, but for the computer I wanted a native solution
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.