Skip to content

Compiler warning: Dereferencing NULL pointer 'print_error' #1911

Closed

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.

Activity

  1. dsnopek commented on Jan 27, 2026

    @dsnopek
    Collaborator

    Ah, yeah, we manually load print_error early on. We should just not try to load print_error again later

  2. dsnopek commented on Jan 27, 2026

    @dsnopek
    Collaborator

    I just posted PR #1912 which should fix this, but I haven't tested it on MSVC. Please let me know if it works for you!

  3. brycehutchings commented on Jan 27, 2026

    @brycehutchings
    Author

    I just posted PR #1912 which should fix this, but I haven't tested it on MSVC. Please let me know if it works for you!

    Confirmed, no more compiler warnings/errors! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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