_ready never called on inherited GDExtension node in Release x86_x64

Using Godot version 4.2.stable.official.46dc27791.
Using godot-cpp latest commit at d6e5286.

In this simple example, the _ready function will never be called on InheritedTest when the extension is compiled in Release x86_64 and is linking to libgodot-cpp.windows.template_release.x86_64.lib. It works in Debug mode when linking to libgodot-cpp.windows.template_debug.x86_64.lib.

I can verify that the function is never called (and not just optimized away) because it also happens in my real extension (below is a minimal reproduction).

class BaseTest : public Node
{
public:
    GDCLASS(BaseTest, Node);

public:
    static void _bind_methods()
    {
    }
};

class InheritedTest : public BaseTest
{
public:
    GDCLASS(InheritedTest, BaseTest);

public:
    static void _bind_methods()
    {
    }

    void _ready()
    {
        OS::get_singleton()->alert(U"Never called");
    }
};
GDREGISTER_CLASS(BaseTest);
GDREGISTER_CLASS(InheritedTest);

Add InheritedTest to the main scene, build in Release and start Godot. InheritedTest::_ready should be called, but it is not. Test in Debug, and it is called.

I have not been able to figure this out. Any ideas?

Fixed: I had /OPT:ICF and /Gy enabled which ended up merging both _bind_methods into the same function, so the _get_bind_methods comparison in initialize_class inside GDCLASS ended up being false, since the InheritedTest and BaseTest functions ended up having the same address.

See:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.