public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
@ 2021-06-28 10:17 redi at gcc dot gnu.org
  2021-06-28 10:22 ` [Bug c++/101239] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-28 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101239
           Summary: "Internal compiler error: Error reporting routines
                    re-entered." in size_in_bytes_loc
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

This valid code produces an ICE:

template<typename T>
struct Blerk
{
  template<typename Ptr>
    static constexpr auto
    type(Ptr p = Ptr(), int n = 0)
    -> decltype(p[n])
    { return false; }

  template<typename Ptr>
    static constexpr int
    type(...)
    { return 1; }

  decltype(type<T*>()) f() const;
};

struct S;
extern Blerk<S[]> p;
auto s = p.f();
struct S { };


ice.C: In substitution of 'template<class Ptr> static constexpr decltype (p[n])
Blerk<S []>::type(Ptr, int) [with Ptr = S (*)[]]':
ice.C:15:20:   required from 'struct Blerk<S []>'
ice.C:20:11:   required from here
ice.C:7:18: error: invalid use of array with unspecified bounds
    7 |     -> decltype(p[n])
      |                 ~^
ice.C: In instantiation of 'struct Blerk<S []>':
ice.C:20:11:   required from here
ice.C:15:20: error: call of overloaded 'type()' is ambiguous
   15 |   decltype(type<T*>()) f() const;
      |            ~~~~~~~~^~
'
Internal compiler error: Error reporting routines re-entered.
0x138c3fd size_in_bytes_loc(unsigned int, tree_node const*)
        /home/jwakely/src/gcc/gcc/gcc/tree.c:3486
0x138c3fd size_in_bytes_loc(unsigned int, tree_node const*)
        /home/jwakely/src/gcc/gcc/gcc/tree.c:3474
0xb5b6ec pointer_int_sum(unsigned int, tree_code, tree_node*, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/c-family/c-common.c:3301
0xb3b078 cp_build_array_ref(unsigned int, tree_node*, tree_node*, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/typeck.c:3708
0x8f2036 build_new_op_1
        /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6743
0x8f25ad build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node**, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6772
0xb295df build_x_array_ref(unsigned int, tree_node*, tree_node*, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/typeck.c:4385
0xaa51b4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:19874
0xac2677 tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:16119
0x9b0580 dump_template_bindings
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:482
0x9a9ba7 dump_substitution
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:1638
0x9a9ba7 dump_substitution
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:1630
0x9a9ba7 dump_function_decl
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:1796
0x9b1a18 decl_to_string
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:3216
0x9b1a18 cp_printer
        /home/jwakely/src/gcc/gcc/gcc/cp/error.c:4389
0x1c6ed6c pp_format(pretty_printer*, text_info*)
        /home/jwakely/src/gcc/gcc/gcc/pretty-print.c:1475
0x1c52850 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /home/jwakely/src/gcc/gcc/gcc/diagnostic.c:1275
0x1c556b7 diagnostic_impl
        /home/jwakely/src/gcc/gcc/gcc/diagnostic.c:1437
0x1c556b7 inform(unsigned int, char const*, ...)
        /home/jwakely/src/gcc/gcc/gcc/diagnostic.c:1516
0x8e1cb6 print_z_candidate
        /home/jwakely/src/gcc/gcc/gcc/cp/call.c:3782
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.

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
@ 2021-06-28 10:22 ` redi at gcc dot gnu.org
  2021-06-28 13:23 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-28 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-06-28

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This slight variation using noexcept in the trailing-return-type was
rejects-valid in 4.7 but is ice-on-valid-code from 4.8 onwards (with the same
ICE):

template<typename T>
struct Blerk
{
  template<typename Ptr>
    static constexpr auto
    type(Ptr p = Ptr(), int n = 0)
    -> decltype(noexcept(p[n]))
    { return false; }

  template<typename Ptr>
    static constexpr int
    type(...)
    { return 1; }

  decltype(type<T*>()) f() const;
};

struct S;
extern Blerk<S[]> p;
auto s = p.f();
struct S { };

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
  2021-06-28 10:22 ` [Bug c++/101239] " redi at gcc dot gnu.org
@ 2021-06-28 13:23 ` cvs-commit at gcc dot gnu.org
  2021-10-01 10:32 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-28 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-1844-gb7a89c041aa1d67654f1ba7b2839e221c3e14748
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 28 12:59:19 2021 +0100

    libstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]

    PR libstdc++/101236 shows that LLVM depends on being able to use
    unique_ptr<T[]>::operator[] when T is incomplete. This is undefined, but
    previously worked with libstdc++. When I added the conditional noexcept
    to that operator we started to diagnose the incomplete type.

    This change restores support for that case, by making the noexcept
    condition check that the type is complete before checking whether
    indexing on the pointer can throw.  A workaround for PR c++/101239 is
    needed to avoid a bogus error where G++ fails to do SFINAE on the
    ill-formed p[n] expression and gets an ICE. Instead of checking that the
    p[n] expression is valid in the trailing-return-type, we only check that
    the element_type is complete.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101236
            * include/bits/unique_ptr.h (unique_ptr<T[], D>::operator[]):
            Fail gracefully if element_type is incomplete.
            * testsuite/20_util/unique_ptr/cons/incomplete.cc: Clarify that
            the standard doesn't require this test to work for array types.
            * testsuite/20_util/unique_ptr/lwg2762.cc: Check that incomplete
            types can be used with array specialization.
            * testsuite/20_util/unique_ptr/101236.cc: New test.

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
  2021-06-28 10:22 ` [Bug c++/101239] " redi at gcc dot gnu.org
  2021-06-28 13:23 ` cvs-commit at gcc dot gnu.org
@ 2021-10-01 10:32 ` pinskia at gcc dot gnu.org
  2021-12-13 19:32 ` arthur.j.odwyer at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-01 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |24663

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect the real issue is with zero sized arrays which we had problems with
before; PR 24663 .


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24663
[Bug 24663] Template instantiation generating a zero-sized array doesn't fail

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-10-01 10:32 ` pinskia at gcc dot gnu.org
@ 2021-12-13 19:32 ` arthur.j.odwyer at gmail dot com
  2021-12-14  0:02 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2021-12-13 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot com

--- Comment #4 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
I believe I just hit this as well. Here's a C++20 reproducer:

    auto f(auto a) -> decltype(a+1) { return a+1; }
    struct Incomplete *p;
    auto b = f(p);

The problem seems to be something about over-eager hard-erroring on pointer
arithmetic with incomplete types, because GCC also rejects this valid code:

    auto f(auto a) requires requires { a+1; } { return a+1; }
    auto f(auto a) { return a; }
    struct Incomplete *p;
    auto b = f(p);

(Should call the unconstrained overload; but GCC hard-errors instead.)

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-12-13 19:32 ` arthur.j.odwyer at gmail dot com
@ 2021-12-14  0:02 ` pinskia at gcc dot gnu.org
  2021-12-27 15:01 ` cvs-commit at gcc dot gnu.org
  2021-12-27 15:02 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14  0:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Arthur O'Dwyer from comment #4)
> The problem seems to be something about over-eager hard-erroring on pointer
> arithmetic with incomplete types, because GCC also rejects this valid code:

I split that issue out into PR 103700 which I think is unrelated to the array
size of 0 issue listed here.

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-12-14  0:02 ` pinskia at gcc dot gnu.org
@ 2021-12-27 15:01 ` cvs-commit at gcc dot gnu.org
  2021-12-27 15:02 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-27 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:916ec36d0a3ef3fe44c1657746922a5f18b60326

commit r12-6124-g916ec36d0a3ef3fe44c1657746922a5f18b60326
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Dec 27 10:01:42 2021 -0500

    c++: Add testcase for SFINAE w/ p[N] and incomplete type [PR101239]

    The r12-6123 fix for SFINAE with p+N and incomplete type also fixed
    the analogous issue with p[N].

            PR c++/101239

    gcc/testsuite/ChangeLog:

            * g++.dg/template/sfinae32a.C: New test.

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

* [Bug c++/101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc
  2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-12-27 15:01 ` cvs-commit at gcc dot gnu.org
@ 2021-12-27 15:02 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-27 15:02 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

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

end of thread, other threads:[~2021-12-27 15:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 10:17 [Bug c++/101239] New: "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc redi at gcc dot gnu.org
2021-06-28 10:22 ` [Bug c++/101239] " redi at gcc dot gnu.org
2021-06-28 13:23 ` cvs-commit at gcc dot gnu.org
2021-10-01 10:32 ` pinskia at gcc dot gnu.org
2021-12-13 19:32 ` arthur.j.odwyer at gmail dot com
2021-12-14  0:02 ` pinskia at gcc dot gnu.org
2021-12-27 15:01 ` cvs-commit at gcc dot gnu.org
2021-12-27 15:02 ` ppalka 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).