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

            Bug ID: 87297
           Summary: [9 Regression] ICE on strncpy with an undeclared
                    argument
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The following ill-formed test case triggers an ICE:

$ cat t.c && gcc -S -Wall t.c
struct S { char a[4]; };

void g (struct S *p, const char *s)
{
  __builtin_strncpy (c->a, s, sizeof p->a);
}
t.c: In function ‘g’:
t.c:5:22: error: ‘c’ undeclared (first use in this function)
5 |   __builtin_strncpy (c->a, s, sizeof p->a);
  |                      ^
t.c:5:22: note: each undeclared identifier is reported only once for each
function it appears in
t.c:5:3: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in sizeof_pointer_memaccess_warning, at
c-family/c-warn.c:816
5 |   __builtin_strncpy (c->a, s, sizeof p->a);
  |   ^~~~~~~~~~~~~~~~~
0x141f756 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /ssd/src/gcc/svn/gcc/tree.c:9417
0x7ea3ff tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /ssd/src/gcc/svn/gcc/tree.h:3239
0x9494fc sizeof_pointer_memaccess_warning(unsigned int*, tree_node*,
vec<tree_node*, va_gc, vl_embed>*, tree_node**, bool (*)(tree_node*,
tree_node*))
        /ssd/src/gcc/svn/gcc/c-family/c-warn.c:816
0x880aec c_parser_postfix_expression_after_primary
        /ssd/src/gcc/svn/gcc/c/c-parser.c:9176
0x88030f c_parser_postfix_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:9015
0x879f4a c_parser_unary_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:7278
0x879418 c_parser_cast_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:7119
0x877a36 c_parser_binary_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:6922
0x8771bb c_parser_conditional_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:6656
0x876ea9 c_parser_expr_no_commas
        /ssd/src/gcc/svn/gcc/c/c-parser.c:6573
0x88127f c_parser_expression
        /ssd/src/gcc/svn/gcc/c/c-parser.c:9325
0x8814db c_parser_expression_conv
        /ssd/src/gcc/svn/gcc/c/c-parser.c:9358
0x874481 c_parser_statement_after_labels
        /ssd/src/gcc/svn/gcc/c/c-parser.c:5551
0x8734dc c_parser_compound_statement_nostart
        /ssd/src/gcc/svn/gcc/c/c-parser.c:5089
0x872eaa c_parser_compound_statement
        /ssd/src/gcc/svn/gcc/c/c-parser.c:4923
0x86d6fe c_parser_declaration_or_fndef
        /ssd/src/gcc/svn/gcc/c/c-parser.c:2351
0x86bb9d c_parser_external_declaration
        /ssd/src/gcc/svn/gcc/c/c-parser.c:1644
0x86b6a1 c_parser_translation_unit
        /ssd/src/gcc/svn/gcc/c/c-parser.c:1524
0x8a1458 c_parse_file()
        /ssd/src/gcc/svn/gcc/c/c-parser.c:18403
0x91d06a c_common_parse_file()
        /ssd/src/gcc/svn/gcc/c-family/c-opts.c:1139
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to