Skip to content

[C++4OpenCL] Constructor address space overloading not prioritizing specific address spaces #49673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
OleStrohm opened this issue May 13, 2021 · 3 comments
Labels
bugzilla Issues migrated from bugzilla confirmed Verified by a second party OpenCL

Comments

@OleStrohm
Copy link
Contributor

Bugzilla Link 50329
Version trunk
OS Linux
CC @AnastasiaStulova

Extended Description

struct Foo {
int x;

Foo() __generic = default;
Foo() __private = default;

};

kernel void k() {
__private Foo f;
}

https://godbolt.org/z/nGrdPacWY

This gives the error: call to constructor of '__private Foo' is ambiguous

But since __private is more specific than __generic this should choose Foo() __private as it is the most specific constructor, rather than consider them equally specific.

@AnastasiaStulova
Copy link
Contributor

It seems like it works for other member functions but not for the special members e.g ctors

struct Foo {
int x;

void foo() __generic;
void foo() __private;

};

kernel void k() {
__private Foo f;
f.foo();
}

Perhaps there is a different logic for the overload selection in the special members.

@AnastasiaStulova
Copy link
Contributor

I was checking the other special members and for dtor there seem to be another issue

struct Foo {
int x;

 ~Foo() __generic;
 ~Foo() __private;

};

kernel void k() {
__private Foo f;
f.~Foo();
}

The overload resolution works fine but the automatic destructor is selected with generic address space instead of private.

call spir_func void @​_ZN3FooD1Ev(%struct.Foo* nonnull dereferenceable(4) %1) #​3, !dbg !​24
%2 = addrspacecast %struct.Foo* %1 to %struct.Foo addrspace(4), !dbg !​25
call spir_func void @​_ZNU3AS43FooD1Ev(%struct.Foo addrspace(4)
nonnull dereferenceable(4) %2) #​3, !dbg !​25

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@HoBoIs
Copy link
Contributor

HoBoIs commented Oct 5, 2023

The originally found bug was solved in clang 13.0.0
https://godbolt.org/z/7ndacbbvq
But the we still call the generic destructor in implicit destructor calls.
https://godbolt.org/z/b5qzeoGKa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla confirmed Verified by a second party OpenCL
Projects
None yet
Development

No branches or pull requests

4 participants