Since OCCT 7.1.0 same type attributes may have different GUIDs. Because of this the attribute constructor does not initialize GUID. See a chapter "Support of several attributes of one type at the same label" in Release Notes.

So, before AddAttribute you should call

nameAtt->SetID(TDataStd_Name::GetID())

Anyway, the standard way to create and attach attribute to a label is to use "Set" method of the attribute. It works well on any version of OCCT.

I registered an issue 29371 in the bugtracker to avoid such a problem later.