public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type
@ 2023-06-04 17:46 fchelnokov at gmail dot com
  2023-06-04 19:00 ` [Bug c++/110114] [13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: fchelnokov at gmail dot com @ 2023-06-04 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110114
           Summary: ICE on calling overloaded function in case of
                    incomplete argument type
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program

struct A {
    int a,b;
};

struct B;

void foo(const A &) {}
void foo(const B &) {}

int main() {
    foo({.a=0});
}

is accepted by Clang and MSVC, but GCC 13 crashes on it with the message:

<source>:11:8: internal compiler error: Segmentation fault
   11 |     foo({.a=0});
      |     ~~~^~~~~~~~
0x1ce67fe internal_error(char const*, ...)
        ???:0
0x751149 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x8eaa5c finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x89f99b c_parse_file()
        ???:0
0x98c2b9 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Online demo: https://godbolt.org/z/z7KPGrWsz

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
@ 2023-06-04 19:00 ` pinskia at gcc dot gnu.org
  2023-06-04 19:02 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-04 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-06-04
           Keywords|                            |ice-on-valid-code,
                   |                            |needs-bisection
      Known to fail|                            |13.1.0
      Known to work|                            |11.3.0, 12.1.0, 12.2.0,
                   |                            |12.3.0
   Target Milestone|---                         |13.2
            Summary|ICE on calling overloaded   |[13/14 Regression] ICE on
                   |function in case of         |calling overloaded function
                   |incomplete argument type    |in case of incomplete
                   |                            |argument type
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
  2023-06-04 19:00 ` [Bug c++/110114] [13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-06-04 19:02 ` pinskia at gcc dot gnu.org
  2023-06-05 20:27 ` [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-04 19:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also ICEs on a simple invalid case:
```

struct B;

void foo(const B &) {}

int main() {
    foo({.a=0});
}
```

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
  2023-06-04 19:00 ` [Bug c++/110114] [13/14 Regression] " pinskia at gcc dot gnu.org
  2023-06-04 19:02 ` pinskia at gcc dot gnu.org
@ 2023-06-05 20:27 ` mpolacek at gcc dot gnu.org
  2023-07-18 21:54 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-06-05 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r13-1227:

commit 6c72f1bfc3469422460d86314a081353632d4bcb
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 23 14:41:19 2022 -0400

    c++: designated init cleanup [PR105925]

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (2 preceding siblings ...)
  2023-06-05 20:27 ` [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers mpolacek at gcc dot gnu.org
@ 2023-07-18 21:54 ` mpolacek at gcc dot gnu.org
  2023-07-18 22:05 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-07-18 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (3 preceding siblings ...)
  2023-07-18 21:54 ` mpolacek at gcc dot gnu.org
@ 2023-07-18 22:05 ` mpolacek at gcc dot gnu.org
  2023-07-20 14:33 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-07-18 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This should work; I'll test it tomorrow.

--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -986,6 +986,11 @@ build_aggr_conv (tree type, tree ctor, int flags,
tsubst_flags_t complain)
   tree empty_ctor = NULL_TREE;
   hash_set<tree, true> pset;

+  /* We've called complete_type on TYPE before calling this function, but
+     perhaps it wasn't successful.  */
+  if (!COMPLETE_TYPE_P (type))
+    return nullptr;
+
   /* We already called reshape_init in implicit_conversion, but it might not
      have done anything in the case of parenthesized aggr init.  */

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

* [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (4 preceding siblings ...)
  2023-07-18 22:05 ` mpolacek at gcc dot gnu.org
@ 2023-07-20 14:33 ` cvs-commit at gcc dot gnu.org
  2023-07-20 14:53 ` [Bug c++/110114] [13 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-20 14:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:2cb0dc866e8f95151df5d759157708108e850dd9

commit r14-2677-g2cb0dc866e8f95151df5d759157708108e850dd9
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Jul 19 08:47:29 2023 -0400

    c++: fix ICE with designated initializer [PR110114]

    r13-1227 added an assert checking that the index in a CONSTRUCTOR
    is a FIELD_DECL.  That's a reasonable assumption but in this case
    we never called reshape_init due to the type being incomplete, and
    so the index remained an identifier node: get_class_binding never
    got around to looking up the FIELD_DECL.

    We can avoid the crash by returning early in implicit_conversion_1; we'd
    return NULL anyway due to:

      if (i < CONSTRUCTOR_NELTS (ctor))
        return NULL;

    in build_aggr_conv.

            PR c++/110114

    gcc/cp/ChangeLog:

            * call.cc (implicit_conversion_1): Return early if the type isn't
            complete.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist100.C: Adjust expected diagnostic.
            * g++.dg/cpp2a/desig28.C: New test.
            * g++.dg/cpp2a/desig29.C: New test.

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

* [Bug c++/110114] [13 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (5 preceding siblings ...)
  2023-07-20 14:33 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 14:53 ` mpolacek at gcc dot gnu.org
  2023-07-20 16:06 ` mpolacek at gcc dot gnu.org
  2023-07-27  9:26 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-07-20 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13/14 Regression] ICE on   |[13 Regression] ICE on
                   |calling overloaded function |calling overloaded function
                   |in case of incomplete       |in case of incomplete
                   |argument type and C++       |argument type and C++
                   |designated initializers     |designated initializers

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug c++/110114] [13 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (6 preceding siblings ...)
  2023-07-20 14:53 ` [Bug c++/110114] [13 " mpolacek at gcc dot gnu.org
@ 2023-07-20 16:06 ` mpolacek at gcc dot gnu.org
  2023-07-27  9:26 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-07-20 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The GCC 13 branch is frozen so I'll put this aside for now.

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

* [Bug c++/110114] [13 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers
  2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
                   ` (7 preceding siblings ...)
  2023-07-20 16:06 ` mpolacek at gcc dot gnu.org
@ 2023-07-27  9:26 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.2                        |13.3

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.

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

end of thread, other threads:[~2023-07-27  9:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-04 17:46 [Bug c++/110114] New: ICE on calling overloaded function in case of incomplete argument type fchelnokov at gmail dot com
2023-06-04 19:00 ` [Bug c++/110114] [13/14 Regression] " pinskia at gcc dot gnu.org
2023-06-04 19:02 ` pinskia at gcc dot gnu.org
2023-06-05 20:27 ` [Bug c++/110114] [13/14 Regression] ICE on calling overloaded function in case of incomplete argument type and C++ designated initializers mpolacek at gcc dot gnu.org
2023-07-18 21:54 ` mpolacek at gcc dot gnu.org
2023-07-18 22:05 ` mpolacek at gcc dot gnu.org
2023-07-20 14:33 ` cvs-commit at gcc dot gnu.org
2023-07-20 14:53 ` [Bug c++/110114] [13 " mpolacek at gcc dot gnu.org
2023-07-20 16:06 ` mpolacek at gcc dot gnu.org
2023-07-27  9:26 ` 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).