r/cpp • • Jan 02 '26

Every LLM hallucinates that std::vector deletes elements in a LIFO order

251 Upvotes

118 comments sorted by

View all comments

Show parent comment

1

u/The_JSQuareD Jan 02 '26

Well the 'correct' response by an LLM would be to note that complexity, and either ask for clarification from the user or state a reasonable assumption about what the user meant and proceed under that assumption. I think it's reasonable for OP to call out that none of the current LLMs seem to do that, and aside from not noting the hidden complexity, also give an answer which is simply wrong under the (implicit) assumptions that were made.

Of course, this isn't particularly surprising, but it is worth keeping in mind.

Beyond that, I learned something new myself, so I'm happy OP brought this up; I would have thought the standard makes some guarantee about the order of destruction, but apparently it doesn't. I think it should, though.