Bug 86574 - ICE on std::prev with ranges::view::transform
Summary: ICE on std::prev with ranges::view::transform
Status: RESOLVED DUPLICATE of bug 87814
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-18 19:20 UTC by tower120
Modified: 2021-09-09 20:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-07-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tower120 2018-07-18 19:20:29 UTC
The following code cause ICE on gcc 9. And have malfunction build on all 
previous versions (program compiles, but hangs); clang compiles with error about bidirectional iterator.

https://wandbox.org/permlink/bPT0llOGPqouv3CM

#include <iostream>
#include <vector>
#include <range/v3/view/transform.hpp>


struct Data{
    int x,y;
};

int main() {
    std::vector<Data> datas = { Data{0,1}, Data{1,2}, Data{1,3} };

    const auto xs = datas
                    | ranges::view::transform([](const Data& data) -> int{ return data.x; });

    // no compiler errors / ICEs, but assembled executable - malfunction -
    // program hungs, as soon as reach std::prev
    //auto j = std::prev(xs.end());  

    auto j = std::prev(xs.end(), 1);

    std::cout << "Done" << std::endl;

    return 0;
}


Error message:

In file included from /opt/wandbox/range-v3/include/range/v3/view/transform.hpp:26,
                 from prog.cc:3:
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp: In instantiation of 'constexpr ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true> >::adaptor_cursor(Args&& ...) [with Args = {__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true>}; typename meta::v1::detail::_if_<meta::v1::list<std::is_same<std::integer_sequence<bool, std::is_constructible<Ts, Args>::type::value ...>, std::integer_sequence<bool, (std::is_constructible<Ts, Args>::type::value) || true ...> >, int>, std::integral_constant<bool, true> >::type <anonymous> = 0][inherited from ranges::v3::compressed_tuple_detail::compressed_tuple_<meta::v1::list<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true> >, std::integer_sequence<long unsigned int, 0, 1> >]':
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:183:16:   required from 'constexpr ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true> >::adaptor_cursor(Args&& ...) [with Args = {__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true>}; typename meta::v1::detail::_if_<meta::v1::list<std::is_same<std::integer_sequence<bool, std::is_constructible<Ts, Args>::type::value ...>, std::integer_sequence<bool, (std::is_constructible<Ts, Args>::type::value) || true ...> >, int>, std::integral_constant<bool, true> >::type <anonymous> = 0][inherited from ranges::v3::compressed_tuple_detail::compressed_tuple_<meta::v1::list<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true> >, std::integer_sequence<long unsigned int, 0, 1> >]'
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:405:63:   required from 'static constexpr ranges::v3::adaptor_cursor_t<D> ranges::v3::view_adaptor<Derived, BaseRng, C>::begin_cursor_(D&) [with D = const ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >; Derived = ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >; BaseRng = ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >; ranges::v3::cardinality Cardinality = (ranges::v3::cardinality)-1; ranges::v3::adaptor_cursor_t<D> = ranges::v3::adaptor_cursor<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true> >; typename std::decay<decltype (ranges::v3::range_access::begin_adaptor(declval<D&>(), 42))>::type = ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >::adaptor<true>; typename std::decay<decltype (declval<typename std::decay<decltype (ranges::v3::range_access::begin_adaptor(declval<D&>(), 42))>::type>().begin(declval<D&>()))>::type = __gnu_cxx::__normal_iterator<Data*, std::vector<Data> >]'
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:423:13:   required by substitution of 'template<class D, bool _concept_requires_421, typename std::enable_if<(_concept_requires_421 || (typename ranges::v3::concepts::Same::same<C, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > >, ranges::v3::indirected<main()::<lambda(const Data&)> > > >::type() && ranges::v3::concepts::models<ranges::v3::concepts::Range, const ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > > >())), void>::type* <anonymous> > constexpr decltype (ranges::v3::view_adaptor<ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >, ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, (ranges::v3::cardinality)-1>::begin_cursor_<D>(declval<const D&>())) ranges::v3::view_adaptor<ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >, ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, (ranges::v3::cardinality)-1>::begin_cursor<D, _concept_requires_421, <enumerator> >() const [with D = ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >; bool _concept_requires_421 = false; typename std::enable_if<(_concept_requires_421 || (typename ranges::v3::concepts::Same::same<C, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > >, ranges::v3::indirected<main()::<lambda(const Data&)> > > >::type() && ranges::v3::concepts::models<ranges::v3::concepts::Range, const ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > > >())), void>::type* <anonymous> = 0]'
/opt/wandbox/range-v3/include/range/v3/range_access.hpp:178:48:   required by substitution of 'template<class Rng> static constexpr decltype (static_cast<const Rng&>(rng).begin_cursor()) ranges::v3::range_access::begin_cursor(Rng&, int) [with Rng = const ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >]'
/opt/wandbox/range-v3/include/range/v3/view_facade.hpp:35:68:   required by substitution of 'template<class Derived> using facade_sentinel_t = meta::v1::if_<typename ranges::v3::concepts::Same::same<typename std::decay<decltype (ranges::v3::range_access::begin_cursor(declval<Derived&>(), 42))>::type, typename std::decay<decltype (ranges::v3::range_access::end_cursor(declval<Derived&>(), 42))>::type>::type, ranges::v3::basic_iterator<typename std::decay<decltype (ranges::v3::range_access::begin_cursor(declval<Derived&>(), 42))>::type>, typename std::decay<decltype (ranges::v3::range_access::end_cursor(declval<Derived&>(), 42))>::type> [with Derived = const ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >]'
/opt/wandbox/range-v3/include/range/v3/view_facade.hpp:111:48:   required by substitution of 'template<class D, bool _concept_requires_110, typename std::enable_if<(_concept_requires_113 || typename ranges::v3::concepts::Same::same<C, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > >, ranges::v3::indirected<main()::<lambda(const Data&)> > > >::type()), void>::type* <anonymous> > ranges::v3::detail::facade_sentinel_t<const D> ranges::v3::view_facade<ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >, (ranges::v3::cardinality)-1>::end<D, _concept_requires_110, <enumerator> >() const [with D = ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data> >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data> > >, ranges::v3::indirected<main()::<lambda(const Data&)> > >; bool _concept_requires_110 = false; typename std::enable_if<(_concept_requires_113 || typename ranges::v3::concepts::Same::same<C, ranges::v3::iter_transform_view<ranges::v3::iterator_range<__gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >, __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > > >, ranges::v3::indirected<main()::<lambda(const Data&)> > > >::type()), void>::type* <anonymous> = 0]'
prog.cc:16:31:   required from here
/opt/wandbox/range-v3/include/range/v3/view_adaptor.hpp:183:16: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12200
         struct adaptor_cursor
                ^~~~~~~~~~~~~~
0x589b33 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
	../../source/gcc/cp/pt.c:12200
0x6af1b2 tsubst_template_args
	../../source/gcc/cp/pt.c:12433
0x6af06c tsubst_template_args
	../../source/gcc/cp/pt.c:12451
0x6b1f28 tsubst_aggr_type
	../../source/gcc/cp/pt.c:12664
0x6a607b tsubst(tree_node*, tree_node*, int, tree_node*)
	../../source/gcc/cp/pt.c:14285
0x6af182 tsubst_template_args
	../../source/gcc/cp/pt.c:12462
0x6b1f28 tsubst_aggr_type
	../../source/gcc/cp/pt.c:12664
0x6a607b tsubst(tree_node*, tree_node*, int, tree_node*)
	../../source/gcc/cp/pt.c:14285
0x6b55a5 tsubst_qualified_id
	../../source/gcc/cp/pt.c:15176
0x6b6658 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:18032
0x6bb9ad tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:17727
0x6bb9ad maybe_instantiate_noexcept(tree_node*, int)
	../../source/gcc/cp/pt.c:23655
0x609c4c start_preparsed_function(tree_node*, tree_node*, int)
	../../source/gcc/cp/decl.c:15296
0x64e991 synthesize_method(tree_node*)
	../../source/gcc/cp/method.c:913
0x6a8404 instantiate_decl(tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:24056
0x5e25eb instantiate_cx_fn_r
	../../source/gcc/cp/constexpr.c:4862
0xd6850b walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../source/gcc/tree.c:11422
0xd6880d walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../source/gcc/tree.c:11740
0xd681a0 walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*))
	../../source/gcc/tree.c:11766
0x5e98dd instantiate_constexpr_fns
	../../source/gcc/cp/constexpr.c:4881
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Marek Polacek 2018-07-18 20:30:08 UTC
fatal error: range/v3/view/transform.hpp: No such file or directory

Please provide a preprocessed source file so that we can reproduce.
Comment 2 tower120 2018-07-19 09:59:28 UTC
I can't provide a preprocessed source file, but "range/v3/view/transform.hpp" source is here:

https://github.com/ericniebler/range-v3
Comment 3 Marek Polacek 2018-07-19 13:08:28 UTC
Why couldn't you?  Just use -save-temps.
Comment 4 tower120 2018-07-19 15:35:32 UTC
Because I don't have gcc 9 locally installed. I saw that ICE on https://wandbox.org/permlink/bPT0llOGPqouv3CM

Error message says to report - I'm reporting.
Comment 5 ensadc 2018-11-05 17:55:05 UTC
Duplicate of bug 86212 or bug 87814?
Comment 6 Andrew Pinski 2021-09-09 20:21:07 UTC
Dup of bug 87814.  Fixed in GCC 9.

*** This bug has been marked as a duplicate of bug 87814 ***