Skip to content

[SYCL] error: ambiguous conversion for functional-style cast from 'int' to 'bfloat16' when call bfloat16(0) #4871

Closed
@GHGmc2

Description

@GHGmc2

background: on framework or library side, we often call T(0) to initialize type T with zero value, and T maybe float or integer type

  • reproduce
#include "CL/sycl.hpp"
#include <sycl/ext/intel/experimental/bfloat16.hpp>

using bfloat16 = sycl::ext::intel::experimental::bfloat16;

int main() {
  auto val = bfloat16(0);

  return 0;
}
  • error
ctor.cc:7:14: error: ambiguous conversion for functional-style cast from 'int' to 'bfloat16' (aka 'sycl::ext::intel::experimental::bfloat16')
  auto val = bfloat16(0);
             ^~~~~~~~~~
/home/gta/intel/linux_prod/compiler/linux/bin/../include/sycl/ext/intel/experimental/bfloat16.hpp:47:3: note: candidate constructor
  bfloat16(const storage_t &a) : value(a) {}
  ^
/home/gta/intel/linux_prod/compiler/linux/bin/../include/sycl/ext/intel/experimental/bfloat16.hpp:50:3: note: candidate constructor
  bfloat16(const float &a) { value = from_float(a); }
  ^
1 error generated.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions