This is your problem. Use 'New' instead of 'getmem' - i.e., New (a, 3 * sizeof (NameStr)); or New (a, sizeof (shortarray)); or better still, just "New (a);"
Thanks for your answers. But I want my sources to stay BP/Delphi compatible... I still don't know what is wrong with the getmem call. Maybe I should try this example with a newer compiler as Maurice says it works fine for him. It worked fine for me with BP, Delphi and FPC, but all those handle strings in somewhat different manner than GPC. Why is new better than getmem in this example ?
Because automatic initialisation is run that way.
This also goes for FPC and Delphi, not only GPC. Probably you were just lucky, or the compiler was able to detect what you meant.
Or Delphi and FPC used shortstring for this, and GPC schemata. But if you'd use automated types in FPC/Delphi (like ansistring/dynamic arrays) you could run into these problems too. NEW is really better.