From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EE52B3858C60; Tue, 17 Jan 2023 11:52:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE52B3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673956376; bh=fMR99cUKeIsp36QMWY5wXCV1F7Aw6Q5sgIZXo+MIxxo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=njen3u4DpVtcT+RgvCWzZiiyxtknpUnYR7eiQQ9AVNzEpqhKsJcAqundqON+xrkqX NVmS6gxhVaZU9csutBD2gOFHKf2YM6e/gs51fvdbmE1LRALlJNYrERpu++JOjxVU6p DHxVBG5bJYc0+lYEy5/i9F7ftaedzMX0mHphxwWA= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105769] [11/12/13 Regression] program segmentation fault with -ftree-vectorize and nested lambdas Date: Tue, 17 Jan 2023 11:52:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: needs-bisection, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105769 --- Comment #8 from Jakub Jelinek --- Using last night's trunk, it is: #include #include #include template struct vec { T dat[n]; vec() {} explicit vec(const T& x) { for(size_t i =3D 0; i < n; i++) dat[i] =3D x; } T& operator [](size_t i) { return dat[i]; } const T& operator [](size_t i) const { return dat[i]; } }; template using mat =3D vec>; template using sq_mat =3D mat; using map_t =3D std::function; template using est_t =3D std::function; template using es= t2_t =3D std::function; map_t id_map() { return [](size_t j) -> size_t { return j; }; } template est2_t jacknife(const est_t> est, sq_mat& cov, vec& bias) { return [est, &cov, &bias](map_t map) -> void { bias =3D est(map); for(siz= e_t i =3D 0; i < n; i++) std::cout << bias[i] << std::endl; }; } template void print_cov_ratio() { sq_mat<2, T> cov_jn; vec<2, T> bias; jacknife<2, T>([](map_t map) -> vec<2, T> { vec<2, T> retv; retv[0] =3D 1; retv[1] =3D 1; return retv; }, cov_jn, bias)(id_map()); } struct ab { long long unsigned a; short unsigned b; double operator()() { return a; } ab& operator=3D(double rhs) { a =3D rhs; return *this; } friend std::ostream& operator<<(std::ostream&, const ab&); }; std::ostream& operator<<(std::ostream& os, const ab& x) { os << x.a; return= os; } int main() { std::cout << "will do (ab)" << std::endl; print_cov_ratio(); return 0; } Partition 4: size 64 align 16 cov_jn Partition 0: size 48 align 16 D.5698 bias D.5681 Partition 1: size 32 align 16 D.5683 Partition 2: size 32 align 16 D.5682 where struct struct void D.5698; struct est2_t D.5683; struct est_t D.5682; struct map_t D.5681; struct sq_mat cov_jn; struct vec bias; aka D.5682 is the est argument slot - const est_t> est, D.5683 is= the return slot from jacknife est2_t, D.5698 is the lambda object which contains __est, __cov, __bias and cov_jn and bias the automatic variables in print_cov_ratio and D.5681 return value slot of id_map. main in ltrans optimized dump is mostly serial code with some EH edges, exc= ept for one _M_manager =3D=3D nullptr check (if nullptr it throws bad function call, ot= herwise continues). Now, those vars are referenced in: _12 =3D (long unsigned int) &bias; _15 =3D (long unsigned int) &cov_jn; _21 =3D {_15, _12}; ... MEM[(struct vec *)&cov_jn] =3D{v} {CLOBBER}; bias =3D{v} {CLOBBER}; MEM[(struct function *)&D.5682] =3D{v} {CLOBBER}; MEM [(struct _Function_base *)&D.5682] =3D {}; MEM [(bool (*) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5682= + 16B] =3D _8; __ct_comp (&D.5698.__est, &D.5682); ... MEM [(void *)&D.5698 + 32B] =3D _21; MEM[(struct function *)&D.5683] =3D{v} {CLOBBER}; MEM[(struct function *)&D.5683].D.5217 =3D {}; MEM[(struct function *)&D.5683]._M_invoker =3D 0B; ... _14 =3D &MEM[(struct struct void *)_13].__est; __ct_comp (_14, &D.5698.__est); ... MEM[(struct struct void * &)&D.5683] =3D _13; MEM [(bool (*) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5683= + 16B] =3D _7; __dt_base (&MEM[(struct function *)&D.5698].D.5235); D.5698 =3D{v} {CLOBBER}; D.5698 =3D{v} {CLOBBER(eol)}; MEM [(struct _Function_base *)&D.5681] =3D {}; MEM [(bool (*) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5681= + 16B] =3D _84; _18 =3D MEM[(const struct _Function_base *)&D.5683]._M_manager; ... _19 =3D D.5683._M_invoker; _19 (&D.5683.D.5217._M_functor, &D.5681); ... __dt_base (&D.5681.D.5223); D.5681 =3D{v} {CLOBBER}; D.5681 =3D{v} {CLOBBER(eol)}; __dt_base (&D.5683.D.5217); D.5683 =3D{v} {CLOBBER}; __dt_base (&D.5682.D.5235); D.5682 =3D{v} {CLOBBER}; D.5682 =3D{v} {CLOBBER(eol)}; D.5683 =3D{v} {CLOBBER(eol)}; cov_jn =3D{v} {CLOBBER(eol)}; bias =3D{v} {CLOBBER(eol)}; return 0; and some EH stuff.=