* Martin Sebor via Gcc-patches: > This patch depends on the fix for PR 98664 (already approved but > not yet checked in). I've tested it on x86_64-linux. > > To avoid fallout I tried to keep the changes to a minimum, and > so the design isn't as robust as I'd like it ultimately to be. > I plan to enhance it in stage 1.
I've tested this patch on top of 43705f3fa343e08b2fb030460f (so with the PR98664 fix, I think), and the reproducer from PR98512 now ICEs: void * __rawmemchr_ppc (const void *s, int c) { #pragma GCC diagnostics push #pragma GCC diagnostic ignored "-Wstringop-overflow=" #pragma GCC diagnostic ignored "-Wstringop-overread" if (c != 0) return __builtin_memchr (s, c, (unsigned long)-1); #pragma GCC diagnostics pop return (char *)s + __builtin_strlen (s); } extern __typeof (__rawmemchr_ppc) __EI___rawmemchr_ppc __attribute__((alias ("__rawmemchr_ppc"))); during RTL pass: expand t.c: In function ‘__rawmemchr_ppc’: t.c:8:12: internal compiler error: Segmentation fault 8 | return __builtin_memchr (s, c, (unsigned long)-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0xde134f crash_signal /home/bmg/src/gcc/gcc/toplev.c:327 0x9181bd diag_inlining_context::set_locations(vec<unsigned int, va_heap, vl_ptr>*, diagnostic_info*) /home/bmg/src/gcc/gcc/builtins.c:835 0x17ce2da update_effective_level_from_pragmas /home/bmg/src/gcc/gcc/diagnostic.c:1028 0x17ce2da diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) /home/bmg/src/gcc/gcc/diagnostic.c:1218 0x17ceb1e diagnostic_impl /home/bmg/src/gcc/gcc/diagnostic.c:1443 0x17cf144 warning(diagnostic_metadata::location_context&, int, char const*, ...) /home/bmg/src/gcc/gcc/diagnostic.c:1669 0x917ab0 maybe_warn_for_bound /home/bmg/src/gcc/gcc/builtins.c:4077 0x927eee maybe_warn_for_bound /home/bmg/src/gcc/gcc/builtins.c:4920 0x927eee check_access(tree_node*, tree_node*, tree_node*, tree_node*, tree_node*, access_mode, access_data const*) /home/bmg/src/gcc/gcc/builtins.c:4918 0x928b52 check_read_access /home/bmg/src/gcc/gcc/builtins.c:4996 0x92e19b check_read_access /home/bmg/src/gcc/gcc/builtins.c:9992 0x92e19b expand_builtin_memchr /home/bmg/src/gcc/gcc/builtins.c:5926 0x92e19b expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int) /home/bmg/src/gcc/gcc/builtins.c:9992 0xa6d714 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /home/bmg/src/gcc/gcc/expr.c:11275 0xa796fb store_expr(tree_node*, rtx_def*, int, bool, bool) /home/bmg/src/gcc/gcc/expr.c:5885 0xa7ab71 expand_assignment(tree_node*, tree_node*, bool) /home/bmg/src/gcc/gcc/expr.c:5621 0x9569bb expand_call_stmt /home/bmg/src/gcc/gcc/cfgexpand.c:2837 0x9569bb expand_gimple_stmt_1 /home/bmg/src/gcc/gcc/cfgexpand.c:3843 0x9569bb expand_gimple_stmt /home/bmg/src/gcc/gcc/cfgexpand.c:4007 0x95c60f expand_gimple_basic_block /home/bmg/src/gcc/gcc/cfgexpand.c:6044 Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill