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

            Bug ID: 88065
           Summary: [9 Regression] ICE in -Wsizeof-pointer-memaccess on an
                    invalid strncpy
           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: ---

GCC 9 fails with an ICE on the following test case:

$ cat u.c && gcc -S -Wall u.c
struct B { struct A { char b[4]; } a; };

void f (struct B *p)
{
  __builtin_strncpy (q->a.b, "123", sizeof p->a.b);
}
u.c: In function ‘f’:
u.c:5:22: error: ‘q’ undeclared (first use in this function)
    5 |   __builtin_strncpy (q->a.b, "123", sizeof p->a.b);
      |                      ^
u.c:5:22: note: each undeclared identifier is reported only once for each
function it appears in
u.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 (q->a.b, "123", sizeof p->a.b);
      |   ^~~~~~~~~~~~~~~~~
0x152375e tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /ssd/src/gcc/git-svn/gcc/tree.c:9710
0x7f5a7d tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /ssd/src/gcc/git-svn/gcc/tree.h:3277
0x96505b 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/git-svn/gcc/c-family/c-warn.c:816
0x88f12a c_parser_postfix_expression_after_primary
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:9331
0x88e1f9 c_parser_postfix_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:9029
0x8881b6 c_parser_unary_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:7292
0x8876bc c_parser_cast_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:7133
0x885dac c_parser_binary_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:6936
0x8855a8 c_parser_conditional_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:6670
0x8852b8 c_parser_expr_no_commas
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:6587
0x88f917 c_parser_expression
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:9486
0x88fb6c c_parser_expression_conv
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:9519
0x882a63 c_parser_statement_after_labels
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:5565
0x881b61 c_parser_compound_statement_nostart
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:5103
0x88154f c_parser_compound_statement
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:4937
0x87bfc2 c_parser_declaration_or_fndef
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:2350
0x87a64e c_parser_external_declaration
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:1652
0x87a1a7 c_parser_translation_unit
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:1532
0x8b1adf c_parse_file()
        /ssd/src/gcc/git-svn/gcc/c/c-parser.c:19609
0x93166f c_common_parse_file()
        /ssd/src/gcc/git-svn/gcc/c-family/c-opts.c:1151
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