public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730
@ 2020-12-16 18:31 gscfq@t-online.de
  2021-01-04 15:31 ` [Bug c++/98329] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gscfq@t-online.de @ 2020-12-16 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98329
           Summary: [11 Regression] ICE in cp_build_bit_cast, at
                    cp/semantics.c:10730
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Follow-up of pr98193, with test case derived from bit-cast7.C
(similar for other files bit-cast*.C).
Gives an ICE with modifications like "&from", "*from", "**from"
"-from", "--from", etc. at marker "///" :


$ cat z1.cc
template <typename To, typename From>
constexpr To
bit_cast (const From &from)
{
  return __builtin_bit_cast (To, &from); ///
}

struct J
{
  long int a, b : 11, h;
};

struct K
{
  long int a, b : 11, c;
  constexpr bool operator == (const K &x)
  {
    return a == x.a && b == x.b && c == x.c;
  }
};

struct L
{
  long long int a, b : 11, h;
};
struct M
{
  long long int a, b : 11, c;
  constexpr bool operator == (const M &x)
  {
    return a == x.a && b == x.b && c == x.c;
  }
};

static_assert (bit_cast <K> (J{}) == K{}, "");
static_assert (bit_cast <M> (L{0x0feedbacdeadbeefLL}) ==
M{0x0feedbacdeadbeefLL}, "");


$ g++-11-20201213 -c z1.cc
z1.cc: In instantiation of 'constexpr To bit_cast(const From&) [with To = K;
>From = J]':
z1.cc:35:33:   required from here
z1.cc:5:30: internal compiler error: Segmentation fault
    5 |   return __builtin_bit_cast (To, &from); ///
      |                              ^~
0xf86f4f crash_signal
        ../../gcc/toplev.c:327
0x911421 cp_build_bit_cast(unsigned int, tree_node*, tree_node*, int)
        ../../gcc/cp/semantics.c:10730
0x89765f tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/cp/pt.c:20747
0x8bca30 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.c:19007
0x8bb83f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.c:18084
0x8bc9ef tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.c:18398
0x8a12c5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.c:18059
0x8a12c5 instantiate_body
        ../../gcc/cp/pt.c:25728
0x8a2b8f instantiate_decl(tree_node*, bool, bool)
        ../../gcc/cp/pt.c:26017
0x6e697c instantiate_cx_fn_r
        ../../gcc/cp/constexpr.c:6951
0x12dbc13 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12095
0x12dc53d walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12431
0x12dc478 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12335
0x12dc53d walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12431
0x12e0245 walk_tree_without_duplicates_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false,
default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:12457
0x6f5858 instantiate_constexpr_fns
        ../../gcc/cp/constexpr.c:6971
0x6f5858 cxx_eval_outermost_constant_expr
        ../../gcc/cp/constexpr.c:7125
0x6fa6b4 maybe_constant_value(tree_node*, tree_node*, bool)
        ../../gcc/cp/constexpr.c:7381
0x90f76d finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
        ../../gcc/cp/semantics.c:9932
0x82de02 cp_parser_static_assert
        ../../gcc/cp/parser.c:15365

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

* [Bug c++/98329] [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730
  2020-12-16 18:31 [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730 gscfq@t-online.de
@ 2021-01-04 15:31 ` rguenth at gcc dot gnu.org
  2021-01-07 10:53 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-04 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

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

* [Bug c++/98329] [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730
  2020-12-16 18:31 [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730 gscfq@t-online.de
  2021-01-04 15:31 ` [Bug c++/98329] " rguenth at gcc dot gnu.org
@ 2021-01-07 10:53 ` jakub at gcc dot gnu.org
  2021-01-07 22:01 ` cvs-commit at gcc dot gnu.org
  2021-01-14 11:08 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-07 10:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-01-07

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49908
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49908&action=edit
gcc11-pr98329.patch

Thanks for the report.  Untested fix attached.

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

* [Bug c++/98329] [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730
  2020-12-16 18:31 [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730 gscfq@t-online.de
  2021-01-04 15:31 ` [Bug c++/98329] " rguenth at gcc dot gnu.org
  2021-01-07 10:53 ` jakub at gcc dot gnu.org
@ 2021-01-07 22:01 ` cvs-commit at gcc dot gnu.org
  2021-01-14 11:08 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-07 22:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r11-6533-gaa4db31dd2a99b4c902f2a3ac6ef4397f84dd888
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 7 23:00:28 2021 +0100

    c++: Fix up tsubst of BIT_CAST_EXPR [PR98329]

    As the testcase shows, calling cp_build_bit_cast in tsubst_copy doesn't
seem
    to be a good idea, because tsubst_copy might not really make the operand
    non-dependent, but as processing_template_decl can be 0,
    type_dependent_expression_p will return false and then cp_build_bit_cast
    assumes the type is non-NULL and non-dependent.
    So, this patch just follows what is done e.g. for NOP_EXPR etc. and just
    builds some tree in tsubst_copy, and only calls the semantics.c function
    from tsubst_copy_and_build.

    2021-01-07  Jakub Jelinek  <jakub@redhat.com>

            PR c++/98329
            * pt.c (tsubst_copy) <case BIT_CAST_EXPR>: Don't call
            cp_build_bit_cast here, instead just build_min a BIT_CAST_EXPR and
set
            its location.
            (tsubst_copy_and_build): Handle BIT_CAST_EXPR.

            * g++.dg/cpp2a/bit-cast10.C: New test.

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

* [Bug c++/98329] [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730
  2020-12-16 18:31 [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-01-07 22:01 ` cvs-commit at gcc dot gnu.org
@ 2021-01-14 11:08 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
           Priority|P3                          |P1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed I assume.

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

end of thread, other threads:[~2021-01-14 11:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 18:31 [Bug c++/98329] New: [11 Regression] ICE in cp_build_bit_cast, at cp/semantics.c:10730 gscfq@t-online.de
2021-01-04 15:31 ` [Bug c++/98329] " rguenth at gcc dot gnu.org
2021-01-07 10:53 ` jakub at gcc dot gnu.org
2021-01-07 22:01 ` cvs-commit at gcc dot gnu.org
2021-01-14 11:08 ` rguenth 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).