https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99433
--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to gcc-bugs from comment #7) > Thank you for the quick analysis! > > > views::drop(E, F) is specified to be expression-equivalent to the braced > > init ranges::drop_view{E, F} > > Is not completely true, right? As the narrowing warning shows: > > ``` > libstdc++-v3/include/std/ranges:2101:24: warning: narrowing conversion of > ‘std::declval<long unsigned int>()’ from ‘long unsigned int’ to > ‘std::ranges::range_difference_t<std::ranges::ref_view<std::__cxx11:: > list<char> > >’ {aka ‘long int’} [-Wnarrowing] > ``` > > There is some `std::views::all` involved. Yeah, that comes from drop_view's deduction guide template<typename _Range> drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; > > But the following expressions > > ``` > #include <list> > #include <ranges> > > int main() > { > std::list<char> list; > // std::views::drop(list, 0ull); // does not compile > std::ranges::drop_view{list, 0ull}; // does compile without warnings > std::ranges::drop_view{std::views::all(list), 0ull}; // does compile > without warnings > } > ``` > > do compile without any warnings when using `g++-11 -std=c++2a -pedantic > -Wall -Wextra`! > > Even when adding `-Wsystem-headers` there is no "narrowing" warning found in > those expressions. Ah, I think that's because 0ull is a constant expression, and a narrowing conversion in a braced init list _is_ allowed if the value is a constant expression that's representable in the target type. If you replace 0ull with some non-constant expression of the same type, the narrowing warning reappears.