Skip to content

Virtual methods that return pointers should only be implementable through an unsafe trait #649

Open
@lilizoey

Description

@lilizoey

Currently when generating virtual methods that take pointers as arguments or return pointers we label the method itself unsafe. However generally speaking, a method that returns a pointer shouldn't cause any UB if it's called wrong. For instance Box::into_raw is a safe method. So it's wrong (though generally harmless) for methods that only return pointers, but doesn't take them as arguments, to be labelled as unsafe.

However when someone implements this trait, they must ensure that the pointer they return from the method satisfies certain criteria. Otherwise they may cause UB. This means that the trait the method is in must be an unsafe trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugc: registerRegister classes, functions and other symbols to GDScriptubUndefined behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions