Skip to content

[Issue]: optional.h uses non-member function with ->  #404

Closed
@yxsamliu

Description

@yxsamliu

Problem Description

A recent clang change (llvm/llvm-project#90152) revealed a bug in rocThrust develop branch

this->construct(std::forward<Args>(args)...);

rocThrust/thrust/../thrust/optional.h:2756:11: error: no member named 'construct' in 'optional<type-parameter-0-0 &>'

In this->construct, the arrow operator cannot be overloaded, therefore it can only access its own member function. However, construct is not its member function, since optional<T &> does not define construct. Although optional<T> inherits construct from its base classes, its member construct is not inherited by optional<T &> since they do not have inherit relation.

Since optional<T &> behaves like a delegate of its member m_value, my guess of intention of this->construct is to
perform m_value->construct, i.e., using the overloaded arrow operator. To make the arrow operator taking effect, (*this)-> can be used. Therefor, the fix is

(*this)->construct(std::forward<Args>(args)...);

Operating System

Ubuntu 22.04

CPU

any

GPU

AMD Radeon Pro W7900

ROCm Version

ROCm 6.1.0

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions