Skip to content

fix(base): copy a const Function instead of wrapping it - #21

Merged
Force67 merged 1 commit into
devel5from
fix/function-const-source
Sep 26, 2026
Merged

Force67 merged 1 commit into
devel5from
fix/function-const-source

Conversation

@Force67

@Force67 Force67 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Function's converting constructor excluded Function itself but not const Function. Moving a closure that captured a Function by copy moves that capture as a const Function&&, which bound to the converting constructor ahead of the copy constructor and wrapped the Function in another Function, and again, until the stack ran out. rx hits this in Renderer::BuildFrameGraph for every scene hook (the pass lambda captures the hook by copy); anyvoxel crashed on its first frame.

StaticFunction's converting constructor and assignment had no constraint at all, so copying a non-const StaticFunction lvalue failed its storage static_assert.

  • Function: IsCallable strips cv-qualifiers (remove_cvref_t)
  • StaticFunction: converting constructor and assignment reject StaticFunction and nullptr
  • tests: Function from a const rvalue and from a moved closure that captured one (both crash before the fix); StaticFunction copy from a non-const lvalue and a const rvalue (did not compile before)

base_unittests 1005/1005.

@Force67
Force67 merged commit bdb537f into devel5 Sep 26, 2026
6 checks passed
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