Skip to content

Add missing return in TemplatedApp move assignment operator - #1946

Open
Dev-next-gen wants to merge 1 commit into
uNetworking:masterfrom
Dev-next-gen:fix/move-assign-missing-return
Open

Dev-next-gen wants to merge 1 commit into
uNetworking:masterfrom
Dev-next-gen:fix/move-assign-missing-return

Conversation

@Dev-next-gen

Copy link
Copy Markdown
Contributor

TemplatedApp::operator=(TemplatedApp&&), added in #1914, is declared to return TemplatedApp& but has no return statement. Flowing off the end of a non-void function is undefined behavior per the C++ standard ([stmt.return]). In practice, if the return value is ever used (e.g. chained assignment a = b = std::move(c)), the caller reads garbage from the stack or a register.

I spotted this while compiling with -Werror=return-type:

src/App.h:264:5: error: no return statement in function returning non-void [-Werror=return-type]

The fix adds the missing return *this;.

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.

The move assignment operator added in uNetworking#1914 is declared to return
TemplatedApp& but has no return statement.  Flowing off the end of a
non-void function is undefined behavior (C++ [stmt.return]).  Add the
missing `return *this;`.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant