https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77842

            Bug ID: 77842
           Summary: genmatch segfault on a missing brace
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Adding following (wrong pattern) to match.pd:

(simplify
  (lt @0 @1)
   (if (integer_zerop (@0))
    {
/* causing segfault:   } */
    ))

Causes segfault in:
Program received signal SIGSEGV, Segmentation fault.
_cpp_lex_direct (pfile=pfile@entry=0x689970) at ../../../libcpp/lex.c:2407
2407      if (buffer->need_line)
(gdb) bt
#0  _cpp_lex_direct (pfile=pfile@entry=0x689970) at ../../../libcpp/lex.c:2407
#1  0x000000000042af9a in _cpp_lex_token (pfile=pfile@entry=0x689970) at
../../../libcpp/lex.c:2291
#2  0x0000000000431778 in cpp_get_token_1 (pfile=0x689970,
location=location@entry=0x0) at ../../../libcpp/macro.c:2462
#3  0x0000000000431a47 in cpp_get_token (pfile=<optimized out>) at
../../../libcpp/macro.c:2604
#4  0x0000000000414de8 in parser::next (this=<optimized out>) at
../../gcc/genmatch.c:3769
#5  parser::parse_c_expr (this=this@entry=0x7fffffffdb30,
start=start@entry=CPP_OPEN_BRACE) at ../../gcc/genmatch.c:4119
#6  0x0000000000415561 in parser::parse_op (this=this@entry=0x7fffffffdb30) at
../../gcc/genmatch.c:4166
#7  0x0000000000415f25 in parser::parse_result (this=this@entry=0x7fffffffdb30,
result=result@entry=0x0, matcher=matcher@entry=0x0) at
../../gcc/genmatch.c:4265
#8  0x0000000000416db4 in parser::parse_simplify
(this=this@entry=0x7fffffffdb30, kind=kind@entry=simplify::SIMPLIFY,
simplifiers=..., matcher=matcher@entry=0x0, result=result@entry=0x0) at
../../gcc/genmatch.c:4415
#9  0x0000000000417003 in parser::parse_pattern
(this=this@entry=0x7fffffffdb30) at ../../gcc/genmatch.c:4649
#10 0x000000000041835d in parser::parser (this=0x7fffffffdb30, r_=<optimized
out>) at ../../gcc/genmatch.c:4735
#11 0x0000000000408a2f in main (argc=<optimized out>, argv=<optimized out>) at
../../gcc/genmatch.c:4833

I don't know whether it worth for fixing, but I'm adding the issue..

Reply via email to