Skip to content

buffer::get_host_access() can't be compiled with gcc 8.4 #6892

@AlexeySachkov

Description

@AlexeySachkov

Describe the bug

While working on some unit-tests for #6815, I discovered that not all host APIs can be compiled with gcc.

To Reproduce

Try to compile the following example with gcc:

#include <sycl/sycl.hpp>

#include <vector>

class A {
public:
  template <int Dimensions, typename T = int>
  void foo(const sycl::range<Dimensions> &range) {
    std::vector<T> data(range.size());
    sycl::buffer<T, Dimensions> buffer(data.data(), range);
    auto accessor = buffer.get_host_access();
    assert(accessor[0] == 42);
  }

  void bar() { foo(sycl::range<1>{10}); }
};

int main() {
  A a;
  a.bar();
  return 0;
}
g++ reproducer.cpp -I path/to/sycl/headers -std=c++17

You will see the following error:

In file included from include/sycl/sycl.hpp:11,
                 from reproducer.cpp:1:
include/sycl/accessor.hpp: In instantiation of ‘auto sycl::_V1::buffer<T, Dimensions, AllocatorT, Enable>::get_host_access(Ts ...) [with Ts = {}; T = int; int dimensions = 1; AllocatorT = sycl::_V1::detail::aligned_allocator<int>; __Enabled = void]’:
reproducer.cpp:11:10:   required from ‘void A::foo(const sycl::_V1::range<Dims>&) [with int Dimensions = 1; T = int]’
reproducer.cpp:15:38:   required from here
include/sycl/accessor.hpp:2805:44: error: ‘IsSameAsBuffer’ was not declared in this scope
             typename = detail::enable_if_t<IsSameAsBuffer<T, Dims>()>>
                                            ^~~~~~~~~~~~~~~~~~~~~~~
include/sycl/accessor.hpp:2805:44: note: suggested alternative: ‘IsSubBuffer’
             typename = detail::enable_if_t<IsSameAsBuffer<T, Dims>()>>
                                            ^~~~~~~~~~~~~~~~~~~~~~~
                                            IsSubBuffer
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template
include/sycl/accessor.hpp:2805:44: error: ‘<typeprefixerror>IsSameAsBuffer’ is not a function template

Additional context

Note that this code can be compiled just fine by clang++. I haven't tried gcc versions other than 8.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions