Skip to content

Compiler warning: Dereferencing NULL pointer 'print_error' #1911

@brycehutchings

Description

@brycehutchings

Godot version

4.6

godot-cpp version

10.0.0-rc1

System information

Windows 11, MSVC compiler with CMake build

Issue description

I have a pretty bespoke build setup for Godot and godot-cpp, so there is a chance I did something wrong when upgrading to 10.0.0-rc1, but I am getting this warning from my compiler:

1>.../godot/godot-cpp/src/gdextension_interface_loader.cpp(507): error C2220: the following warning is treated as an error
1>...\godot\godot-cpp\src\gdextension_interface_loader.cpp(290): warning C6011: Dereferencing NULL pointer 'print_error'. : Lines: 279, 282, 285, 288, 290

And this is because LOAD_PROC_ADDRESS(print_error, GDExtensionInterfacePrintError); expands to:

::godot::gdextension_interface::print_error = (GDExtensionInterfacePrintError)p_get_proc_address("print_error");
if (!::godot::gdextension_interface::print_error) {
    ::godot::gdextension_interface::print_error("Unable to load GDExtension interface function " "print_error" "()", __FUNCTION__, "...\\godot\\godot-cpp\\src\\gdextension_interface_loader.cpp", 290, false);
    return false;
};

So the compiler can see that invoking ::godot::gdextension_interface::print_error in this code path is guaranteed to be a nullptr.

Steps to reproduce

I am doing scons gdextension_dir=(path to where I have Godot editor --dump-extension-api and also I copy core\extension\gdextension_interface.json here) build_library=no

Then I have a custom CMake target that globs up all the output files to create a godot-cpp static library.

Minimal reproduction project

Not feasible to share. Or at least hoping it can be avoided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions