valarray::operator[](slice) const returns _Expr<_SClos<_ValArray,_Tp>, _Tp> instead of slice_array<Tp>, this type cannot be casted (with static_cast) to slice_array<Tp>.
gcc barfs that "conversion from std::_Expr<std::_SClos<std::_ValArray, double>, double> to non-scalar type std::slice_array<double> requested" This concerns only const version of the operator[](slice), normal version works fine. So slice_array objects cannot be created using const valarray objects. P.S. const_cast can be used as a workaround. The example program is attached. -- Summary: valarray::operator[](slice) const returns wrong type. Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: crazydm at gmail dot com GCC build triplet: Using built-in specs. GCC host triplet: GNU/Linux alioth 2.6.25-ARCH #1 SMP PREEMP GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37347