LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 40792 - cannot convert initializer list argument to std::slice_array
Summary: cannot convert initializer list argument to std::slice_array
Status: NEW
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 8.0
Hardware: PC FreeBSD
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-20 11:52 PST by Yuri
Modified: 2019-02-20 12:50 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2019-02-20 11:52:41 PST
The test.c below fails in clang-8, but works with gcc-8.

It is natural that a slice array of equal size is initialized using the initializer list.

It probably shouldn't fail, and implicitly use this operator: void std::slice_array::operator=(const std::valarray<T>& val_arr).


FreeBSD 11.2

Yuri



---test.cpp---
#include <valarray>

void f() {
  typedef std::valarray<double> matrix;
  matrix m;
  m[std::slice(2, 3, 3)] = {0.,0.,0.};
}


---message.txt---
valarray-ilist.cpp:6:26: error: no viable overloaded '='
  m[std::slice(2, 3, 3)] = {0.,0.,0.};
  ~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/c++/v1/valarray:1258:24: note: candidate function not viable: cannot convert initializer list argument to 'const std::__1::slice_array<double>'
    const slice_array& operator=(const slice_array& __sa) const;
                       ^
/usr/include/c++/v1/valarray:1261:10: note: candidate function not viable: cannot convert initializer list argument to 'const std::__1::slice_array<double>::value_type'
      (aka 'const double')
    void operator=(const value_type& __x) const;
         ^
/usr/include/c++/v1/valarray:1165:5: note: candidate template ignored: couldn't infer template argument '_Expr'
    operator=(const _Expr& __v) const;
    ^
Comment 1 Nicolas Lesser 2019-02-20 12:50:16 PST
This isn't a clang bug per se, it's a libc++ issue.