Clankers: code had several
strcasecmp("XYZ", s, 3)
strcasecmp("ABCD", s, 4)
I added
strcasecmp("MN", s, strlen(s))
and Copilot says: "No, no, no. This will read past the length of "MN". Change the length parameter.
🙈
Edit: it was strncasecmp() of course, as @hyc correctly pointed out.
@icing what it lacks in competence, it sure makes up for in confidence
@icing my assumption on what is being checked is likely wrong, but if not, all three comparions are :p (inputs XYZFOO and M)
@jelte Yes, they give wrong results on prefixes. I am fixing that.
However, I wanted to illustrate how the LLM pattern matching goes haywire here...
@icing not strncasecmp?
@hyc yeah, right sorry, miswrote.
@icing
If s has a length of 3, it will. Copilot isn't wrong? The right way to do this is
min(strlen(s), 2).
Unless of course you are able to guarantee in the contextual code that s is never longer than 2.
If s has a length of 3, it will. Copilot isn't wrong? The right way to do this is
min(strlen(s), 2).
Unless of course you are able to guarantee in the contextual code that s is never longer than 2.
- replies
- 0
- announces
- 0
- likes
- 0