Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

cub::TransformInputIterator should not define operator->() #377

@zasdfgbnm

Description

@zasdfgbnm

See:

// nvcc --extended-lambda cub-debug.cu

#include <cub/cub.cuh>

struct Result {
    int64_t value;
};

int main() {
    int64_t a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    auto wrap = [] __host__ __device__ (int64_t a) -> Result { return {a}; };
    cub::TransformInputIterator<Result, decltype(wrap), int64_t *, ptrdiff_t> iter(a, wrap);
    assert((*(iter + 2)).value == 2);

    // The following code does not compile:
    // assert((iter + 2)->value == 2);
    //
    // Error is:
    // /usr/local/cuda/bin/../targets/x86_64-linux/include/cub/iterator/transform_input_iterator.cuh:225:24: error: taking address of rvalue [-fpermissive]
    // 225 |         return &conversion_op(*input_itr);
    //     |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
  
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions