This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR 86572


On Sun, Nov 4, 2018 at 10:02 AM Jeff Law <law@redhat.com> wrote:
>
> On 10/22/18 9:08 AM, Bernd Edlinger wrote:
> > Hi!
> >
> > This makes c_strlen avoid an unsafe strlen folding of const arguments
> > with non-const offset.  Currently a negative out of bounds offset
> > makes the strlen function return an extremely large number, and
> > at the same time, prevents the VRP machinery, to determine the correct
> > range if the strlen function in this case.
> >
> > Fixed by doing the whole computation in size_t and casting the
> > result back to ssize_t.
> >
> >
> > Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> > Is it OK for trunk?
> >
> >
> > Thanks
> > Bernd.
> >
> >
> > patch-pr86572.diff
> >
> > gcc:
> > 2018-10-22  Bernd Edlinger  <bernd.edlinger@hotmail.de>
> >
> >       PR tree-optimization/86572
> >       * builtins.c (c_strlen): Handle negative offsets in a safe way.
> >
> > testsuite:
> > 2018-10-22  Bernd Edlinger  <bernd.edlinger@hotmail.de>
> >
> >       PR tree-optimization/86572
> >       * gcc.dg/pr86572.c: New test.
> OK.
> jeff

This caused:

/export/gnu/import/git/gcc-test-ia32/src-trunk/gcc/testsuite/gcc.dg/warn-strlen-no-nul.c:56:1:
internal compiler error: verify_gimple failed^M
0x8922dc4 verify_gimple_in_seq(gimple*)^M
        ../../src-trunk/gcc/tree-cfg.c:5082^M
0x86899d7 gimplify_body(tree_node*, bool)^M
        ../../src-trunk/gcc/gimplify.c:12859^M
0x8689b8b gimplify_function_tree(tree_node*)^M
        ../../src-trunk/gcc/gimplify.c:12949^M
0x84f7690 cgraph_node::analyze()^M
        ../../src-trunk/gcc/cgraphunit.c:667^M
0x84fa1d8 analyze_functions^M
        ../../src-trunk/gcc/cgraphunit.c:1126^M
0x84fadd3 symbol_table::finalize_compilation_unit()^M
        ../../src-trunk/gcc/cgraphunit.c:2833^M
Please submit a full bug report,^M
with preprocessed source if appropriate.^M
Please include the complete backtrace with any bug report.^M
See <https://gcc.gnu.org/bugs/> for instructions.^M
compiler exited with status 1
FAIL: gcc.dg/warn-strlen-no-nul.c (internal compiler error)

on i386.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]