public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function
@ 2022-04-20 20:08 ppalka at gcc dot gnu.org
  2022-04-20 20:11 ` [Bug c++/105322] " ppalka at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-20 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105322
           Summary: [modules] ICE with constexpr object of local class
                    type from another function
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

Reduced from PR105297:

$ cat 105297.C
constexpr auto foo() {
  struct S { int d; };
  return S{0};
}

inline void bar() {
  constexpr auto t = foo();
}

$ g++ -fmodules-ts 105297.C
105297.C: internal compiler error: in insert, at cp/module.cc:4800
0x6da0fd trees_out::insert(tree_node*, walk_kind)
        /home/patrick/code/gcc/gcc/cp/module.cc:4800
0xa8a4ea trees_out::decl_node(tree_node*, walk_kind)
        /home/patrick/code/gcc/gcc/cp/module.cc:8367
0xa8acf2 trees_out::tree_node(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:9102
0xa8bff1 trees_out::core_vals(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:6090
0xa8eb54 trees_out::tree_node_vals(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:7072
0xa8eb54 trees_out::tree_value(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:8909
0xa8ab54 trees_out::tree_node(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:9107
0xa8b84f trees_out::core_vals(tree_node*)
        /home/patrick/code/gcc/gcc/cp/module.cc:6003

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
@ 2022-04-20 20:11 ` ppalka at gcc dot gnu.org
  2022-04-21 12:35 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-20 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.2.0, 12.0

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Another ICE-on-valid testcase, without constexpr:

auto foo() {
  struct S { int d; };
  return S{};
}

inline void bar() {
  decltype(foo()) r = {0};
}

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
  2022-04-20 20:11 ` [Bug c++/105322] " ppalka at gcc dot gnu.org
@ 2022-04-21 12:35 ` cvs-commit at gcc dot gnu.org
  2022-04-28  3:54 ` guojiufu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:1e6c0e69af8da436e1d1d2d23d8c38410d78ecf2

commit r12-8214-g1e6c0e69af8da436e1d1d2d23d8c38410d78ecf2
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Apr 21 08:34:59 2022 -0400

    libstdc++: Work around modules ICE in <charconv> [PR105297]

    This makes the initializer for __table in __from_chars_alnum_to_val
    dependent in an artificial way, which works around the reported modules
    testsuite ICE by preventing the compiler from evaluating the initializer
    parse time.

    Compared to the alternative workaround of using a non-local class type
    for __table, this workaround has the advantage of slightly speeding up
    compilation of <charconv>, since now the table won't get built (via
    constexpr evaluation) until the integer std::from_chars overload is
    instantiated.

            PR c++/105297
            PR c++/105322

    libstdc++-v3/ChangeLog:

            * include/std/charconv (__from_chars_alnum_to_val): Make
            initializer for __table dependent in an artificial way.

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
  2022-04-20 20:11 ` [Bug c++/105322] " ppalka at gcc dot gnu.org
  2022-04-21 12:35 ` cvs-commit at gcc dot gnu.org
@ 2022-04-28  3:54 ` guojiufu at gcc dot gnu.org
  2022-10-21 19:37 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-28  3:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |guojiufu at gcc dot gnu.org

--- Comment #3 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
One finding:
In trees_out::decl_node, there are code lines:

    case FIELD_DECL:
      {
        if (streaming_p ())
          i (tt_data_member);

        tree ctx = DECL_CONTEXT (decl);
        tree_node (ctx); //The context, is the struct "S" inside foo, "S" is
handled in 'tree_node', and "insert" is called for member "d".

        tree name = NULL_TREE;

        if (TREE_CODE (decl) == USING_DECL)
          ;
        else
          {
            name = DECL_NAME (decl);
            if (name && IDENTIFIER_ANON_P (name))
              name = NULL_TREE;
          }

        tree_node (name);
        if (!name && streaming_p ())
          {
            unsigned ix = get_field_ident (ctx, decl);
            u (ix);
          }

        int tag = insert (decl); //HERE, "insert" is called again member "d". 

It may be a direct cause that "insert" is called twice for "d", and then a
crash occurs.

While I do not know much about the code and do not found a fix.

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-04-28  3:54 ` guojiufu at gcc dot gnu.org
@ 2022-10-21 19:37 ` ppalka at gcc dot gnu.org
  2023-04-26  6:55 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-21 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-10-21
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
   Target Milestone|---                         |13.0
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-10-21 19:37 ` ppalka at gcc dot gnu.org
@ 2023-04-26  6:55 ` rguenth at gcc dot gnu.org
  2023-07-27  9:22 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-04-26  6:55 ` rguenth at gcc dot gnu.org
@ 2023-07-27  9:22 ` rguenth at gcc dot gnu.org
  2023-10-20 20:25 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-07-27  9:22 ` rguenth at gcc dot gnu.org
@ 2023-10-20 20:25 ` cvs-commit at gcc dot gnu.org
  2023-10-24  0:47 ` ppalka at gcc dot gnu.org
  2023-10-24  0:47 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-20 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:084addf8a700fab9222d4127ab8524920d0ca481

commit r14-4806-g084addf8a700fab9222d4127ab8524920d0ca481
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Oct 20 12:20:37 2023 -0400

    c++: Constructor streaming [PR105322]

    An expresion node's type is streamed after the expression's operands,
    because the type can come from some aspect of an operand (for instance
    decltype and noexcept). There's a comment in the code explaining that.

    But that doesn't work for constructors, which can directly reference
    components of their type (eg FIELD_DECLS). If this is a
    type-introducing CONSTRUCTOR, we need to ensure the type has been
    streamed first. So move CONSTRUCTOR stream to after the type streaming.

    The reason things like COMPONENT_REF work is that they stream their
    first operand first, and that introduces the type that their second
    operand looks up a field in.

            gcc/cp/
            PR c++/105322
            * module.cc (trees_out::core_vals): Stream CONSTRUCTOR operands
            after the type.
            (trees_in::core_vals): Likewise.
            gcc/testsuite/
            * g++.dg/modules/decltype-1_a.C: New.
            * g++.dg/modules/decltype-1_b.C: New.
            * g++.dg/modules/lambda-5_a.C: New.
            * g++.dg/modules/lambda-5_b.C: New.

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-10-20 20:25 ` cvs-commit at gcc dot gnu.org
@ 2023-10-24  0:47 ` ppalka at gcc dot gnu.org
  2023-10-24  0:47 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-10-24  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/105322] [modules] ICE with constexpr object of local class type from another function
  2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-10-24  0:47 ` ppalka at gcc dot gnu.org
@ 2023-10-24  0:47 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-10-24  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
.

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

end of thread, other threads:[~2023-10-24  0:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 20:08 [Bug c++/105322] New: [modules] ICE with constexpr object of local class type from another function ppalka at gcc dot gnu.org
2022-04-20 20:11 ` [Bug c++/105322] " ppalka at gcc dot gnu.org
2022-04-21 12:35 ` cvs-commit at gcc dot gnu.org
2022-04-28  3:54 ` guojiufu at gcc dot gnu.org
2022-10-21 19:37 ` ppalka at gcc dot gnu.org
2023-04-26  6:55 ` rguenth at gcc dot gnu.org
2023-07-27  9:22 ` rguenth at gcc dot gnu.org
2023-10-20 20:25 ` cvs-commit at gcc dot gnu.org
2023-10-24  0:47 ` ppalka at gcc dot gnu.org
2023-10-24  0:47 ` 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).