I cannot reproduce your problem. Please provide detailed steps to repeat.
Which version you are using? Is this normal or page-oriented CFC?
Is the problem reproducible "from scratch" (with standard project using template)?
How do you insert the box - with Copy/Paste, with Toolbox, with menu?
Please note, that "function" has not to be declared, so your box is definetely not a function.
sorry for the late reply and a bad choise of words: what I meant by "declaration" was the process of setting the empty object (a new box in CFC) to a reference, i.e. naming it as a function or a fb.
I'm using Codesys 3.5.10 and normal CFC (not page oriented). I inserted the box from the toolbox.
So basically what I did was that I entered a new box to an existing program and connected the leads to other boxes before I gave the object a reference (it was still pointing to '???'). This recreated the same error and when I closed the PRG editor I could not open it again.
The weird part is, that when I tried this on another program, I was able to connect the leads to other boxes before naming the box as anything without getting any error messages whatsoever. I'm going to try this out on an empty program next and see what happens.