So I checked the AS_DEBUG directory where the obj code is generated for CDerivedBar::Foo and there is a line which looks suspicious to me: "2 2 * CALL 432 (CBar::CBar())" (I can paste/send you more if you need).
I tried with an non overridden method (that's the reason of the "ImNotAnOverrideOfTheBaseClass" ) and same line in the corresponding object file.
Is it a bug or is it an intended behavior?
Now, I would probably not notice it if I didn't do some registering to events in the constructor of my base class, and end up with the registration made a multiple time, actually an infinite time because when the event was called, the constructor was too, registering to the event and so on. I could go with an init mehtod to do the registering so it wouldn't be called several times but then I'd loose the advantage of automatic registration/unregistration through constructor and destructor. That would mean no event if you forget to call init and leak if you forget to call deinit.

Share this post

Link to post

Share on other sites

As you said it looks like a bug, I tried to investigate myself and I found out that it was the fact that methods were private that made a base constructor call, there is no such problem with public methods. It seemed to me that it comes from this part of the code in as_compiler.cpp (around line 228 in version 2.20.2):

When it comes at the first if, the node type is snUndefined as it's the private word so it jumps to the else where it sets m_isConstructor to true. Then some lines later, the compiler adds the default constructor call to base class as it thinks it's compiling a constructor.

Now I don't know the code and I don't know if it's the right way to handle the problem but here is a proposition of a fix that seems to work. (I'm working with the Release 2.20.2 so line# may have changed)

Share this post

Link to post

Share on other sites

Thanks for the investigation. The fact that it only happens for private methods explains why the bug hasn't been discovered before, as private methods is still quite new and probably not widely used yet (most scripts probably won't ever use it). I'll try to have this fixed still today.