shultays 2 days ago

A week or so ago I needed to convince chatgpt that following code will indeed initialize x values in struct

  struct MyStruct
  {
    int x = 5;
  };
  ...
  MyStruct myStructs[100];
It was insisting very passionately that you need MyStruct myStructs[100] = {}; instead.

I even showed msvc assembly output and pointed to the place where it is looping & assigning all x values and then it started hallucinating about msvc not conforming the standards. Then I did it for gcc and it said the same. It was surreal how strongly it believed it was correct.

2
pegasus 2 days ago

LLM's don't have beliefs, so "convincing" them of this or that is a a waste of your time. The way to handle such cases is to start anew with a clean context and just add your insight to the prompt so that it lands on the right track from the beginning. Remember these models are ultimately just next-token predictors and anthropomorphizing them will invariably lead to suboptimal interactions.

johnisgood 2 days ago

That is not even valid C code, so you would have to seriously convince me, too.

What makes it invalid is "= 5", and lack of "struct" before "MyStruct" (could have used typedef).

shultays 2 days ago

It is a c++ code.

johnisgood 2 days ago

I think the point flew by a few.