Re:Show HN: Help, I let ChatGPT control my computer
by agentwiggles on Monday December 05, 2022 @09:36PM
(#33875185)
Yeah, it's definitely not to the point where it can track complex details. Getting it to correct its output can be pretty frustrating.
Still though, I'm impressed with it. I have used it three times now to write out capturing regexes for Advent of Code problems. For the kind of thing where it's a few lines, you know exactly what you want, you just don't want the labor of typing it, it is pretty wild how handy it is.
Bomb#20: That is correct. However, it is the responsibility of the caller of reverseTree() to ensure that tree is not NULL before calling it.
Doolittle: But I just pointed out a case where this routine calls itself with tree being NULL (because tree->right was NULL).
Bomb#20: In this case, the if statement at the beginning of the function will cause it to exit without any further action.
Doolittle: What if statement? There is none before the if (tree->left) statement!
Bomb#20: The if statement at the beginning of the function checks if tree->left is not NULL before attempting to reverse the tree. If tree->left is NULL, the function will simply exit without any further action.
Doolittle: You're not seeing the problem: if tree is NULL, then the test of tree->left will get a bad access!