public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100281] New: ICE with SImode pointer assignment in C++
@ 2021-04-27  8:20 krebbel at gcc dot gnu.org
  2021-04-27  9:42 ` [Bug c++/100281] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: krebbel at gcc dot gnu.org @ 2021-04-27  8:20 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
@ 2021-04-27  9:42 ` rguenth at gcc dot gnu.org
  2021-04-27  9:42 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-27  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I don't think different sized pointers are properly handled anywhere.  It may
just happen to "work".  Why would you need such beasts?  There's only one
intptr_t and only one POINTERS_EXTEND_UNSIGNED, only one ptr_mode.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
  2021-04-27  9:42 ` [Bug c++/100281] " rguenth at gcc dot gnu.org
@ 2021-04-27  9:42 ` rguenth at gcc dot gnu.org
  2021-04-27  9:51 ` krebbel at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-27  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
That said, use integer types.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
  2021-04-27  9:42 ` [Bug c++/100281] " rguenth at gcc dot gnu.org
  2021-04-27  9:42 ` rguenth at gcc dot gnu.org
@ 2021-04-27  9:51 ` krebbel at gcc dot gnu.org
  2021-04-27  9:56 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: krebbel at gcc dot gnu.org @ 2021-04-27  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andreas Krebbel <krebbel at gcc dot gnu.org> ---
This is a hard requirement for the z/TPF operating system supported as part of
our IBM Z backend. It happens to work for many years already and they make
extensive use of it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-04-27  9:51 ` krebbel at gcc dot gnu.org
@ 2021-04-27  9:56 ` rguenth at gcc dot gnu.org
  2021-04-27 15:07 ` krebbel at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-27  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |s390

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I see.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-04-27  9:56 ` rguenth at gcc dot gnu.org
@ 2021-04-27 15:07 ` krebbel at gcc dot gnu.org
  2021-05-18  6:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: krebbel at gcc dot gnu.org @ 2021-04-27 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Krebbel <krebbel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #50685|0                           |1
        is obsolete|                            |

--- Comment #5 from Andreas Krebbel <krebbel at gcc dot gnu.org> ---
Created attachment 50689
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50689&action=edit
Fixed patch with testcase

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-04-27 15:07 ` krebbel at gcc dot gnu.org
@ 2021-05-18  6:45 ` cvs-commit at gcc dot gnu.org
  2021-05-20 15:26 ` cvs-commit at gcc dot gnu.org
  2021-08-12 23:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-18  6:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andreas Krebbel <krebbel@gcc.gnu.org>:

https://gcc.gnu.org/g:720dff974ea0487c35c0a4bfa527f30df5066ce1

commit r12-857-g720dff974ea0487c35c0a4bfa527f30df5066ce1
Author: Andreas Krebbel <krebbel@linux.ibm.com>
Date:   Tue Apr 27 10:09:06 2021 +0200

    PR100281 C++: Fix SImode pointer handling

    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.

    gcc/cp/ChangeLog:

            PR c++/100281
            * cvt.c (cp_convert_to_pointer): Use the size of the target
            pointer type.
            * tree.c (cp_build_reference_type): Call
            cp_build_reference_type_for_mode with VOIDmode.
            (cp_build_reference_type_for_mode): Rename from
            cp_build_reference_type.  Add MODE argument and invoke
            build_reference_type_for_mode.
            (strip_typedefs): Use build_pointer_type_for_mode and
            cp_build_reference_type_for_mode for pointers and references.

    gcc/ChangeLog:

            PR c++/100281
            * tree.c (build_reference_type_for_mode)
            (build_pointer_type_for_mode): Pick pointer mode if MODE argument
            is VOIDmode.
            (build_reference_type, build_pointer_type): Invoke
            build_*_type_for_mode with VOIDmode.

    gcc/testsuite/ChangeLog:

            PR c++/100281
            * g++.target/s390/pr100281-1.C: New test.
            * g++.target/s390/pr100281-2.C: New test.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-05-18  6:45 ` cvs-commit at gcc dot gnu.org
@ 2021-05-20 15:26 ` cvs-commit at gcc dot gnu.org
  2021-08-12 23:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-20 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Andreas Krebbel
<krebbel@gcc.gnu.org>:

https://gcc.gnu.org/g:e43f47686980e9d0081aa765b619bdc89189b51a

commit r11-8448-ge43f47686980e9d0081aa765b619bdc89189b51a
Author: Andreas Krebbel <krebbel@linux.ibm.com>
Date:   Tue Apr 27 10:09:06 2021 +0200

    PR100281 C++: Fix SImode pointer handling

    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.

    gcc/cp/ChangeLog:

            PR c++/100281
            * cvt.c (cp_convert_to_pointer): Use the size of the target
            pointer type.
            * tree.c (cp_build_reference_type): Call
            cp_build_reference_type_for_mode with VOIDmode.
            (cp_build_reference_type_for_mode): Rename from
            cp_build_reference_type.  Add MODE argument and invoke
            build_reference_type_for_mode.
            (strip_typedefs): Use build_pointer_type_for_mode and
            cp_build_reference_type_for_mode for pointers and references.

    gcc/ChangeLog:

            PR c++/100281
            * tree.c (build_reference_type_for_mode)
            (build_pointer_type_for_mode): Pick pointer mode if MODE argument
            is VOIDmode.
            (build_reference_type, build_pointer_type): Invoke
            build_*_type_for_mode with VOIDmode.

    gcc/testsuite/ChangeLog:

            PR c++/100281
            * g++.target/s390/pr100281-1.C: New test.
            * g++.target/s390/pr100281-2.C: New test.

    (cherry picked from commit 720dff974ea0487c35c0a4bfa527f30df5066ce1)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/100281] ICE with SImode pointer assignment in C++
  2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-05-20 15:26 ` cvs-commit at gcc dot gnu.org
@ 2021-08-12 23:13 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-12 23:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.2
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |ice-on-valid-code
         Resolution|---                         |FIXED

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed so closing as such.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-08-12 23:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27  8:20 [Bug c++/100281] New: ICE with SImode pointer assignment in C++ krebbel at gcc dot gnu.org
2021-04-27  9:42 ` [Bug c++/100281] " rguenth at gcc dot gnu.org
2021-04-27  9:42 ` rguenth at gcc dot gnu.org
2021-04-27  9:51 ` krebbel at gcc dot gnu.org
2021-04-27  9:56 ` rguenth at gcc dot gnu.org
2021-04-27 15:07 ` krebbel at gcc dot gnu.org
2021-05-18  6:45 ` cvs-commit at gcc dot gnu.org
2021-05-20 15:26 ` cvs-commit at gcc dot gnu.org
2021-08-12 23:13 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).