public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-105769-4-rPB94DVK9T@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105769-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105769 --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Using last night's trunk, it is: #include <iostream> #include <iomanip> #include <functional> template<size_t n, class T> struct vec { T dat[n]; vec() {} explicit vec(const T& x) { for(size_t i = 0; i < n; i++) dat[i] = x; } T& operator [](size_t i) { return dat[i]; } const T& operator [](size_t i) const { return dat[i]; } }; template<size_t m, size_t n, class T> using mat = vec<m, vec<n, T>>; template<size_t n, class T> using sq_mat = mat<n, n, T>; using map_t = std::function<size_t(size_t)>; template<class T_v> using est_t = std::function<T_v(map_t map)>; template<class T_v> using est2_t = std::function<T_v(map_t map)>; map_t id_map() { return [](size_t j) -> size_t { return j; }; } template<size_t n, class T> est2_t<void> jacknife(const est_t<vec<n, T>> est, sq_mat<n, T>& cov, vec<n, T>& bias) { return [est, &cov, &bias](map_t map) -> void { bias = est(map); for(size_t i = 0; i < n; i++) std::cout << bias[i] << std::endl; }; } template<class T> 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] = 1; retv[1] = 1; return retv; }, cov_jn, bias)(id_map()); } struct ab { long long unsigned a; short unsigned b; double operator()() { return a; } ab& operator=(double rhs) { a = 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<ab>(); 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<vec<n, T>> est, D.5683 is the return slot from jacknife est2_t<void>, 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, except for one _M_manager == nullptr check (if nullptr it throws bad function call, otherwise continues). Now, those vars are referenced in: _12 = (long unsigned int) &bias; _15 = (long unsigned int) &cov_jn; _21 = {_15, _12}; ... MEM[(struct vec *)&cov_jn] ={v} {CLOBBER}; bias ={v} {CLOBBER}; MEM[(struct function *)&D.5682] ={v} {CLOBBER}; MEM <char[16]> [(struct _Function_base *)&D.5682] = {}; MEM <vector(2) long unsigned int> [(bool (*<T72d>) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5682 + 16B] = _8; __ct_comp (&D.5698.__est, &D.5682); ... MEM <vector(2) long unsigned int> [(void *)&D.5698 + 32B] = _21; MEM[(struct function *)&D.5683] ={v} {CLOBBER}; MEM[(struct function *)&D.5683].D.5217 = {}; MEM[(struct function *)&D.5683]._M_invoker = 0B; ... _14 = &MEM[(struct struct void *)_13].__est; __ct_comp (_14, &D.5698.__est); ... MEM[(struct struct void * &)&D.5683] = _13; MEM <vector(2) long unsigned int> [(bool (*<T72d>) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5683 + 16B] = _7; __dt_base (&MEM[(struct function *)&D.5698].D.5235); D.5698 ={v} {CLOBBER}; D.5698 ={v} {CLOBBER(eol)}; MEM <char[16]> [(struct _Function_base *)&D.5681] = {}; MEM <vector(2) long unsigned int> [(bool (*<T72d>) (union _Any_data & {ref-all}, const union _Any_data & {ref-all}, _Manager_operation) *)&D.5681 + 16B] = _84; _18 = MEM[(const struct _Function_base *)&D.5683]._M_manager; ... _19 = D.5683._M_invoker; _19 (&D.5683.D.5217._M_functor, &D.5681); ... __dt_base (&D.5681.D.5223); D.5681 ={v} {CLOBBER}; D.5681 ={v} {CLOBBER(eol)}; __dt_base (&D.5683.D.5217); D.5683 ={v} {CLOBBER}; __dt_base (&D.5682.D.5235); D.5682 ={v} {CLOBBER}; D.5682 ={v} {CLOBBER(eol)}; D.5683 ={v} {CLOBBER(eol)}; cov_jn ={v} {CLOBBER(eol)}; bias ={v} {CLOBBER(eol)}; return 0; and some EH stuff.
next prev parent reply other threads:[~2023-01-17 11:52 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-29 21:24 [Bug c++/105769] New: " sliwa at ifpan dot edu.pl 2022-05-30 10:14 ` [Bug tree-optimization/105769] " marxin at gcc dot gnu.org 2022-06-02 8:10 ` [Bug tree-optimization/105769] [11/12/13 Regression] " rguenth at gcc dot gnu.org 2022-10-19 10:15 ` rguenth at gcc dot gnu.org 2022-10-19 11:01 ` marxin at gcc dot gnu.org 2023-01-16 20:30 ` jakub at gcc dot gnu.org 2023-01-16 21:10 ` jakub at gcc dot gnu.org 2023-01-16 21:20 ` jakub at gcc dot gnu.org 2023-01-17 11:52 ` jakub at gcc dot gnu.org [this message] 2023-01-17 12:11 ` jakub at gcc dot gnu.org 2023-01-17 12:27 ` rguenth at gcc dot gnu.org 2023-01-17 12:31 ` jakub at gcc dot gnu.org 2023-01-17 12:41 ` jakub at gcc dot gnu.org 2023-01-17 14:08 ` rguenther at suse dot de 2023-01-17 14:45 ` jakub at gcc dot gnu.org 2023-01-17 15:14 ` rguenther at suse dot de 2023-05-29 10:07 ` [Bug tree-optimization/105769] [11/12/13/14 " jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105769-4-rPB94DVK9T@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).