Skip to content

Fix overload ambiguity errors - #388

Merged
adayton1 merged 1 commit into
developfrom
bugfix/ambiguity
Jul 24, 2026
Merged

Fix overload ambiguity errors#388
adayton1 merged 1 commit into
developfrom
bugfix/ambiguity

Conversation

@adayton1

Copy link
Copy Markdown
Member

care::host_device_ptr had two constructors that sometimes led to compilation errors due to ambiguous overload resolution.

CARE_HOST_DEVICE host_device_ptr(std::nullptr_t from);
CARE_HOST_DEVICE explicit host_device_ptr(size_t elems);

Compilation would fail when constructing a host_device_ptr from the integer literal 0 because the compiler can't decide which overload to pick. Additionally, nvcc erroneously reports ambiguity when constructing from an int in certain cases.

Using a constraint resolves the ambiguity in both of those situations. The nullptr constructor will now only accept nullptr or a variable of type std::nullptr_t. The size_t constructor will get all the rest, including 0.

@adayton1 adayton1 changed the title Fix compilation ambiguity errors Fix overload ambiguity errors Jul 24, 2026
@adayton1
adayton1 merged commit 2d1d31b into develop Jul 24, 2026
32 checks passed
@adayton1
adayton1 deleted the bugfix/ambiguity branch July 24, 2026 22:37
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.

3 participants