From 03f9329e5823868cc65d561ebcefa1f373f57de6 Mon Sep 17 00:00:00 2001 From: LiYanCheng <412998149@qq.com> Date: Sat, 20 Nov 2021 17:42:04 +0800 Subject: [PATCH] Backport PR c++/83227 - C++17 ICE with init-list derived-to-base conversion. --- ...3227-C-17-ICE-with-init-list-derived.patch | 80 +++++++++++++++++++ gcc.spec | 6 ++ 2 files changed, 86 insertions(+) create mode 100644 Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch diff --git a/Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch b/Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch new file mode 100644 index 0000000..46b54c2 --- /dev/null +++ b/Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch @@ -0,0 +1,80 @@ +From ac9de5374b4e2f4aa45c0e4f720a9727b44ab534 Mon Sep 17 00:00:00 2001 +From: LiYanCheng <412998149@qq.com> +Date: Sat, 20 Nov 2021 15:50:38 +0800 +Subject: [PATCH] Backport PR c++/83227 - C++17 ICE with init-list + derived-to-base conversion. + +--- + gcc/cp/ChangeLog | 6 ++++++ + gcc/cp/call.c | 9 +++++---- + gcc/testsuite/g++.dg/cpp0x/initlist98.C | 17 +++++++++++++++++ + 3 files changed, 28 insertions(+), 4 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist98.C + +diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog +index b5d15c7b6..6aa0075b5 100644 +--- a/gcc/cp/ChangeLog ++++ b/gcc/cp/ChangeLog +@@ -1,3 +1,9 @@ ++2018-02-15 Jason Merrill ++ ++ PR c++/83227 - C++17 ICE with init-list derived-to-base conversion. ++ * call.c (convert_like_real): Don't use the copy-list-initialization ++ shortcut for ck_base. ++ + 2018-01-25 Release Manager + + * GCC 7.3.0 released. +diff --git a/gcc/cp/call.c b/gcc/cp/call.c +index 56f6b9323..0993c2acf 100644 +--- a/gcc/cp/call.c ++++ b/gcc/cp/call.c +@@ -6886,6 +6886,11 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, + && DECL_INHERITED_CTOR (current_function_decl)) + return expr; + ++ if (TREE_CODE (expr) == TARGET_EXPR ++ && TARGET_EXPR_LIST_INIT_P (expr)) ++ /* Copy-list-initialization doesn't actually involve a copy. */ ++ return expr; ++ + /* Fall through. */ + case ck_base: + if (convs->kind == ck_base && !convs->need_temporary_p) +@@ -6911,10 +6916,6 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, + flags |= LOOKUP_ONLYCONVERTING; + if (convs->rvaluedness_matches_p) + flags |= LOOKUP_PREFER_RVALUE; +- if (TREE_CODE (expr) == TARGET_EXPR +- && TARGET_EXPR_LIST_INIT_P (expr)) +- /* Copy-list-initialization doesn't actually involve a copy. */ +- return expr; + expr = build_temp (expr, totype, flags, &diag_kind, complain); + if (diag_kind && complain) + { +diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist98.C b/gcc/testsuite/g++.dg/cpp0x/initlist98.C +new file mode 100644 +index 000000000..4f2fcd202 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/initlist98.C +@@ -0,0 +1,17 @@ ++// PR c++/83227 ++// { dg-do compile { target c++11 } } ++ ++#include ++ ++template struct f { ++ f(std::initializer_list) {} ++}; ++ ++struct h {}; ++struct i : h { ++ i(); ++}; ++void foo(f); ++int main() { ++ foo({i{}}); ++} +-- +2.27.0 + diff --git a/gcc.spec b/gcc.spec index b4251a6..f5cc492 100644 --- a/gcc.spec +++ b/gcc.spec @@ -88,6 +88,7 @@ Patch35: turn-on-funwind-tables-by-default.patch Patch36: fix-trivially_constructible-PR81589.patch Patch37: Add-full-steady_clock-support-to-condition_variable.patch Patch38: fix-pre-improve-fake-exit-edge-placement.patch +Patch39: Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch #AutoReqProv: off AutoReq: true @@ -550,6 +551,7 @@ package or when debugging this package. %patch36 -p1 %patch37 -p1 %patch38 -p1 +%patch39 -p1 %if 0%{?_enable_debug_packages} cat > split-debuginfo.sh <<\EOF @@ -3290,6 +3292,10 @@ fi %changelog +* Sat Nov 20 2021 liyancheng <412998149@qq.com> - 7.3.0-20211120.42 +- Backport-PR-c-83227-C-17-ICE-with-init-list-derived.patch: New file +- gcc.spec: Add new patch + * Tue Jul 27 2021 yuanxin - 7.3.0-20210719.41 - Type:bugfix - ID:NA -- Gitee