https://gcc.gnu.org/g:c0b52c7383e311d970984ae66941d6267de3199d
commit r17-6108-gc0b52c7383e311d970984ae66941d6267de3199d Author: Richard Biener <[email protected]> Date: Tue Nov 10 09:34:26 2026 +0100 ipa/128592 - check matching -fwrapv-pointer during inlining The following adds a missed check on matching flag_wrapv_pointer. PR ipa/128592 * ipa-inline.cc (can_inline_edge_by_limits_p): Check flag_wrapv_pointer matches. * gcc.dg/lto/pr128592_0.c: New testcase. * gcc.dg/lto/pr128592_1.c: Likewise. Diff: --- gcc/ipa-inline.cc | 1 + gcc/testsuite/gcc.dg/lto/pr128592_0.c | 13 +++++++++++++ gcc/testsuite/gcc.dg/lto/pr128592_1.c | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc index ba8bf11b66ee..261962ed746f 100644 --- a/gcc/ipa-inline.cc +++ b/gcc/ipa-inline.cc @@ -587,6 +587,7 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, int flags) we cannot inline in these cases for correctness reason. Not even for always_inline declared functions. */ else if (check_match (flag_wrapv) + || check_match (flag_wrapv_pointer) || check_match (flag_trapv) || check_match (flag_pcc_struct_return) || check_maybe_down (optimize_debug) diff --git a/gcc/testsuite/gcc.dg/lto/pr128592_0.c b/gcc/testsuite/gcc.dg/lto/pr128592_0.c new file mode 100644 index 000000000000..73341bf6817c --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr128592_0.c @@ -0,0 +1,13 @@ +/* { dg-lto-do link } */ +/* { dg-require-linker-plugin "" } */ +/* { dg-lto-options { { -O2 -flto -fdump-tree-optimized } } } */ + + +int callee_ptr(const char *p); +int main () +{ + char s[16]; + return callee_ptr(s); +} + +/* { dg-final { scan-ltrans-tree-dump-not "return 0;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/lto/pr128592_1.c b/gcc/testsuite/gcc.dg/lto/pr128592_1.c new file mode 100644 index 000000000000..28f660cba75f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr128592_1.c @@ -0,0 +1,6 @@ +/* { dg-options "-fwrapv-pointer" } */ + +int +callee_ptr(const char *p) { + return (p + 16 < p); +}
