#how is this even possible?

55 messages · Page 1 of 1 (latest)

oblique voidBOT
#

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.

wanton ginkgo
#

Se comment in code about IDE saying this if statement is always false

#

like that's not true...right?

signal comet
#

what if statement?

manic tree
wanton ginkgo
#

Well

#

Turns out, it was incorrect

#

the static analysis was wrong

#

@manic tree

manic tree
#

Do you still have the code that was giving that warning?

wanton ginkgo
#

Yes

#

It still gives the warning, I need to adjust clion to like turn of static analysis for that function

#

Let me show you

manic tree
#

mind if you share?

wanton ginkgo
#

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

manic tree
#

duh

#

What condition is always false?

wanton ginkgo
#

last if statement

manic tree
#

Can't copy it into an IDE without rebooting to Linux

wanton ginkgo
#

You don't sound like a beginner

#

sus

manic tree
#

so, if (largest != i) is always false according to your IDE

#

So largest == i is apparently always true

#

okay, lemme follow the control flow

wanton ginkgo
#

Logically it makes 0 sense lol

#

regardless of what getRight and getLeft return

#

values can be a vector in any order

manic tree
#

What does getLeft return?

wanton ginkgo
#

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

manic tree
#

hmm, okay. Very weird

wanton ginkgo
#

For instance, Visual Studio 2022

#

doesn't say this

#

only clion

#

so, if that means anything

manic tree
#

Damn, okay. Sorry for not believing you, but you have to admit, whout providing some code this does sound kinda sus

wanton ginkgo
#

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

manic tree
#

or at least I wouldn't feel comfortable advertising myself as an intermediate

wanton ginkgo
#

What type of code you write?

#

You mentioned linux so systems programming?

manic tree
#

Nah, I'm still in uni actually

#

But I have a SSD for Linux only

wanton ginkgo
#

Oh ok fair enough, same here

manic tree
#

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

oblique voidBOT
#

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.