Skip to content

Delete operator=(const m_class &p_rval) on wrapper classes - #2027

Open
dsnopek wants to merge 1 commit into
godotengine:masterfrom
dsnopek:delete-operator-equals
Open

Delete operator=(const m_class &p_rval) on wrapper classes#2027
dsnopek wants to merge 1 commit into
godotengine:masterfrom
dsnopek:delete-operator-equals

Conversation

@dsnopek

@dsnopek dsnopek commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1995

This seems like it'd be OK, given that the previous operator=(const m_class &p_rval) did nothing, and we don't really want wrapper classes to be copyable by value (they should always be pointers)

But I'm not 100% sure that I understand the full implications - it'd be great to get feedback from someone with stronger C++ knowledge!

FYI, Godot's Object also declares an empty operator=(const m_class &p_rval) - if this makes sense in godot-cpp, maybe it should also be deleted in Godot as well?

@dsnopek dsnopek added this to the 10.x milestone Jul 25, 2026
@dsnopek
dsnopek requested a review from a team as a code owner July 25, 2026 12:02
@dsnopek dsnopek added the bug This has been identified as a bug label Jul 25, 2026
@dsnopek
dsnopek force-pushed the delete-operator-equals branch from 190daa0 to 8857e28 Compare July 25, 2026 12:36
@dsnopek
dsnopek force-pushed the delete-operator-equals branch from 8857e28 to e65e9ad Compare July 25, 2026 12:36

@Ivorforce Ivorforce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Probably should do the same upstream; it's also using the {} version.

I've seen at least 3 instances of people on discord being confused about Object ownership (using Object as a stack local instead of a pointer) and then getting weird issues when using operator=. This should improve the situation at least a bit.

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

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

operator= in Wrapped.hpp produces deprecated warnings

2 participants