Try the following code: -------- #include <vector> #include <range/v3/action.hpp> int main(){ std::vector<int> v{1,2,3,4,5}; v | ::ranges::v3::to<std::pmr::vector>; } -------- godbolt link:https://godbolt.org/z/oxnbad9M6
Am I right, the code is invalid?
This stumps me. I don't know if the code is valid or not. But these code compiles: ---- v | ::ranges::v3::to<std::vector>; ---- v | ::ranges::v3::to_vector; ---- So I guess the code is more likely to be valid?
Then let's mark it as ICE on valid code.
Good, looking forward to it being fixed.
Looks like the original testcase is indeed valid, but one needs to include <memory_resource> as well (for pmr::polymorphic_allocator). Reduced: template<class T, class U> struct A { A(T, U); }; template<class T, class U> using B = A<U, T>; using type = decltype(B{0, 0});
(In reply to Patrick Palka from comment #5) > but one needs to include > <memory_resource> as well (for pmr::polymorphic_allocator). For libstdc++ the <vector> header only declares the pmr::vector alias, without defining prm::polymorphic_allocator. That means pmr::vector is an incomplete type unless you also include <memory_resource>. This is permitted by the standard, and avoids paying to include <memory_resource> if you don't plan to use the pmr types.
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:a8b3861496bffae8b813ea196c1c5b27f79fbe69 commit r12-2378-ga8b3861496bffae8b813ea196c1c5b27f79fbe69 Author: Patrick Palka <ppalka@redhat.com> Date: Fri Jul 16 16:21:13 2021 -0400 c++: alias CTAD in unevaluated context [PR101233] This is the alias CTAD version of the CTAD bug PR93248, and the fix is the same: clear cp_unevaluated_operand so that the entire chain of DECL_ARGUMENTS gets substituted. PR c++/101233 gcc/cp/ChangeLog: * pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for substituting DECL_ARGUMENTS. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias10.C: New test.
The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:9107b139f4492d504df37e943882405e6aefdb7e commit r11-8762-g9107b139f4492d504df37e943882405e6aefdb7e Author: Patrick Palka <ppalka@redhat.com> Date: Fri Jul 16 16:21:13 2021 -0400 c++: alias CTAD in unevaluated context [PR101233] This is the alias CTAD version of the CTAD bug PR93248, and the fix is the same: clear cp_unevaluated_operand so that the entire chain of DECL_ARGUMENTS gets substituted. PR c++/101233 gcc/cp/ChangeLog: * pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for substituting DECL_ARGUMENTS. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias10.C: New test. (cherry picked from commit a8b3861496bffae8b813ea196c1c5b27f79fbe69)
Fixed for GCC 11.2 and 12.