Here is some code I wrote today for practice.
This code has a terrible, evil bug that causes it to seg-fault.
Can you spot the bug?
(Note: Compiling it = cheating. Compilation with -Wall reveals the answer.)
... irrelevant code snipped ...
bool HeapEmpty()
{
return HeapSize == 0;
}
void HandleGroup(uint i)
{
// Is the heap empty?
if (HeapEmpty()) {
// Nothing to do with this group =\
return;
}
// Get the currently valid trip that has the least chance of attracting more groups.
uint TIdx = HeapExtractMin();
// Match!
NumMatched++;
Match[Arr[i].Index + 1] = TIdx + 1;
}
... irrelevant code snipped ...
either the uint thing or something else :(.
It's never going to return, even if the heap is empty.
QuoteChange "=\" to "=/" is my best guess. It seems you commented out return on accident.
The only reason I know this is because I have done the same thing (though it would seem that my mistake (forgetting to add to a number) is less severe than yours). Yay for syntax highlighting! I've never coded in pico since. vim for life.
Newby rocks.
QuoteActually, it might return, just not from the "return;" line. :)
But, as soon as we hit HeapExtractMin(), it tries to extract from an empty heap, which sometimes crashes and otherwise returns junk.
Quote from: Yoni on July 29, 2005, 05:12 PM
Newby rocks.
QuoteActually, it might return, just not from the "return;" line. :)
But, as soon as we hit HeapExtractMin(), it tries to extract from an empty heap, which sometimes crashes and otherwise returns junk.
:)
QuoteYeah, I guess I should have specified that it won't return from that return line if no heap exists.
That's also a reason why I use /* code blocks */ :)
:)
Why do you talk like this?
Cause they want to look cool
It's a spoiler blocker. If you don't want to see the answer you don't have to.
I think they're using a different theme, since not all themes have black quotes.