hcc
hcc copied to clipboard
C++ class constructor not being called in some cases
In this example on host side cpu constructor of Inner is not called if gpu constructor is marked as default:
int main()
{
struct Inner
{
Inner() [[cpu]]
{
printf("Inner\n");
}
Inner() [[hc]] = default;
};
struct Outer
{
Inner in;
};
Outer out;
return 0;
}
This prints nothing.
When is gpu constructor removed or empty then is cpu constructor called:
int main()
{
struct Inner
{
Inner() [[cpu]]
{
printf("Inner\n");
}
Inner() [[hc]] {}
};
struct Outer
{
Inner in;
};
Outer out;
return 0;
}
This correctly prints "Inner".
Interesting is that in this third example constructor of Inner is called:
int main()
{
struct Inner
{
Inner() [[cpu]]
{
printf("Inner\n");
}
Inner() [[hc]] = default;
};
Inner in;
return 0;
}
I can reproduce this with latest rocm 1.9 release. We've opened an internal ticket for this.