[Bug c++/100281] New: ICE with SImode pointer assignment in C++

krebbel at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 27 08:20:06 GMT 2021


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

            Bug ID: 100281
           Summary: ICE with SImode pointer assignment in C++
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50685
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50685&action=edit
Experimental Fix

typedef void * __attribute__((mode (SI))) __ptr32_t;

void foo(){
  unsigned int b = 100;
  __ptr32_t a;
  a = b;
}

Building with "cc1plus t.cpp" ICEs on s390x:

 void foo()
in strip_typedefs, at cp/tree.c:1770
    6 |   a = b;
      |       ^
0x156f731 strip_typedefs(tree_node*, bool*, unsigned int)
        /home2/andreas/build/../gcc/gcc/cp/tree.c:1770
0x135c827 type_to_string
        /home2/andreas/build/../gcc/gcc/cp/error.c:3298
0x136c723 cxx_format_postprocessor::handle(pretty_printer*)
        /home2/andreas/build/../gcc/gcc/cp/error.c:4242
0x291f171 pp_format(pretty_printer*, text_info*)
        /home2/andreas/build/../gcc/gcc/pretty-print.c:1496
0x28ffecb diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /home2/andreas/build/../gcc/gcc/diagnostic.c:1244
0x2902cef diagnostic_impl
        /home2/andreas/build/../gcc/gcc/diagnostic.c:1406
0x2902cef permerror(rich_location*, char const*, ...)
        /home2/andreas/build/../gcc/gcc/diagnostic.c:1688
0x12441f7 convert_like_internal
        /home2/andreas/build/../gcc/gcc/cp/call.c:7581
0x12460e1 convert_like
        /home2/andreas/build/../gcc/gcc/cp/call.c:8114
0x12463b3 convert_like
        /home2/andreas/build/../gcc/gcc/cp/call.c:8126
0x12463b3 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        /home2/andreas/build/../gcc/gcc/cp/call.c:12303
0x1599687 cp_build_modify_expr(unsigned int, tree_node*, tree_code, tree_node*,
int)
        /home2/andreas/build/../gcc/gcc/cp/typeck.c:8887
0x159b66d build_x_modify_expr(unsigned int, tree_node*, tree_code, tree_node*,
int)
        /home2/andreas/build/../gcc/gcc/cp/typeck.c:8978
0x1435d8d cp_parser_assignment_expression
        /home2/andreas/build/../gcc/gcc/cp/parser.c:10184
0x1437661 cp_parser_expression
        /home2/andreas/build/../gcc/gcc/cp/parser.c:10313
0x143b5c1 cp_parser_expression_statement
        /home2/andreas/build/../gcc/gcc/cp/parser.c:12041
0x1449a71 cp_parser_statement
        /home2/andreas/build/../gcc/gcc/cp/parser.c:11837
0x144bac7 cp_parser_statement_seq_opt
        /home2/andreas/build/../gcc/gcc/cp/parser.c:12189
0x144bbc7 cp_parser_compound_statement
        /home2/andreas/build/../gcc/gcc/cp/parser.c:12138
0x146ef03 cp_parser_function_body
        /home2/andreas/build/../gcc/gcc/cp/parser.c:24080
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.


The problem appears to be triggered by two locations in the front-end where
non-POINTER_SIZE pointers aren't handled right now.

1. An assertion in strip_typedefs is triggered because the alignment of the
types don't match. This in turn is caused by creating the new type with
build_pointer_type instead of taking the type of the original pointer into
account.
2. An assertion in cp_convert_to_pointer is triggered which expects the target
type to always have POINTER_SIZE.


More information about the Gcc-bugs mailing list