public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772
@ 2022-01-12 16:56 unlvsur at live dot com
  2022-10-18 12:59 ` [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment ppalka at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: unlvsur at live dot com @ 2022-01-12 16:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103994
           Summary: Module ICE in mark_by_value, at cp/module.cc:4772
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

Created attachment 52172
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52172&action=edit
module ICE

module;

#include <gtirb/gtirb.hpp>

export module cfg;

namespace cfg
{
export struct cfg_vertex
{
        gtirb::CfgNode const* cfg_node_ptr{};
        struct edge
        {
                std::size_t to{};
                gtirb::CfgNode const* cfg_node_ptr{};
        };
        std::vector<edge> edges;
};

export inline std::vector<cfg_vertex> get_cfg()
{
        return {};
}
}


g++ -c cfg.cc -O2 -std=c++20 -fmodules-ts

cfg.cc:5:8: internal compiler error: in mark_by_value, at cp/module.cc:4772
    5 | export module cfg;
      |        ^
0x7f8092e45fcf __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7f8092e4607c __libc_start_main_impl
        ../csu/libc-start.c:409

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
@ 2022-10-18 12:59 ` ppalka at gcc dot gnu.org
  2023-02-01 17:33 ` Melven.Roehrig-Zoellner at DLR dot de
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-18 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
            Summary|Module ICE in               |Module ICE in write_var_def
                   |mark_by_value, at           |with global variable in
                   |cp/module.cc:4772           |global module fragment

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
With trunk, it seems we now crash from write_var_def.  Reduced:

$ cat pr103994.C
module;
# 0 "" 1
struct A { A(int) { } };
const A a = 0;
# 3 "" 2

export module pr103994;

export inline A f() { return a; }

$ g++ -fmodules-ts pr103994.C
pr103994.C:4:8: internal compiler error: in write_var_def, at
cp/module.cc:11649
    4 | const A a = 0;
      |        ^~~~~~

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
  2022-10-18 12:59 ` [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment ppalka at gcc dot gnu.org
@ 2023-02-01 17:33 ` Melven.Roehrig-Zoellner at DLR dot de
  2024-01-27 16:10 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Melven.Roehrig-Zoellner at DLR dot de @ 2023-02-01 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Melven.Roehrig-Zoellner at DLR dot de ---
Can confirm this with current trunk (see https://godbolt.org/z/16K1jhrsW).

I stumbled upon this while trying to include the C++ library Eigen in the
global module fragment (same stacktrace)...

Thanks to anyone looking into this!

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
  2022-10-18 12:59 ` [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment ppalka at gcc dot gnu.org
  2023-02-01 17:33 ` Melven.Roehrig-Zoellner at DLR dot de
@ 2024-01-27 16:10 ` ppalka at gcc dot gnu.org
  2024-01-27 16:15 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-27 16:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
We accept the comment #1 testcase after r14-6979, but still ICE on the original
testcase:

cfg.cc:5:9: internal compiler error: in insert, at cp/module.cc:4924
0x77357d trees_out::insert(tree_node*, walk_kind)
        /home/patrick/gcc/gcc/cp/module.cc:4924
0xb55c50 trees_out::decl_value(tree_node*, depset*)
        /home/patrick/gcc/gcc/cp/module.cc:7725
0xb5631a trees_out::decl_node(tree_node*, walk_kind)
        /home/patrick/gcc/gcc/cp/module.cc:8764
0xb57522 trees_out::tree_node(tree_node*)
        /home/patrick/gcc/gcc/cp/module.cc:9326
0xb5c9b5 module_state::write_cluster(elf_out*, depset**, unsigned int,
depset::hash&, unsigned int*, unsigned int*)
        /home/patrick/gcc/gcc/cp/module.cc:14898
0xb5e82e module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
        /home/patrick/gcc/gcc/cp/module.cc:18084
0xb5f544 finish_module_processing(cpp_reader*)
        /home/patrick/gcc/gcc/cp/module.cc:20294
0xaeaea1 c_parse_final_cleanups()
        /home/patrick/gcc/gcc/cp/decl2.cc:5313
0xd31290 c_common_parse_file()
        /home/patrick/gcc/gcc/c-family/c-opts.cc:1319
\

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
                   ` (2 preceding siblings ...)
  2024-01-27 16:10 ` ppalka at gcc dot gnu.org
@ 2024-01-27 16:15 ` ppalka at gcc dot gnu.org
  2024-03-04 16:02 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-27 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-01-27
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reduced testcase exhibiting the latest ICE:

$ cat 103994.H
template <typename> struct TransparentSupport {
  template <typename> using key_arg = int;
};
template <typename Key> struct Map {
  template <typename LookupKey>
  using key_arg = typename TransparentSupport<Key>::template
key_arg<LookupKey>;
};
struct MapKey {
  Map<MapKey> map_;
};

$ g++ -fmodule-header 103994.H
103994.H: internal compiler error: in insert, at cp/module.cc:4924

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
                   ` (3 preceding siblings ...)
  2024-01-27 16:15 ` ppalka at gcc dot gnu.org
@ 2024-03-04 16:02 ` ppalka at gcc dot gnu.org
  2024-03-07 21:39 ` cvs-commit at gcc dot gnu.org
  2024-03-07 21:40 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-04 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
                   ` (4 preceding siblings ...)
  2024-03-04 16:02 ` ppalka at gcc dot gnu.org
@ 2024-03-07 21:39 ` cvs-commit at gcc dot gnu.org
  2024-03-07 21:40 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-07 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC 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:f5c1224708a0cf9cc2770c44bbbe7d0c883942be

commit r14-9374-gf5c1224708a0cf9cc2770c44bbbe7d0c883942be
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Mar 7 16:39:20 2024 -0500

    c++/modules: member alias tmpl partial inst [PR103994]

    Alias templates are weird in that their specializations can appear in
    both decl_specializations and type_specializations.  They're always in
    the decl table, and additionally appear in the type table only at parse
    time via finish_template_type.  There seems to be no good reason for
    them to appear in both tables, and the code paths end up stepping over
    each other in particular for a partial instantiation such as
    A<B>::key_arg<T> in the below modules testcase: the type code path
    (lookup_template_class) wants to set TI_TEMPLATE to the most general
    template whereas the decl code path (tsubst_template_decl called during
    instantiation of A<B>) already set TI_TEMPLATE to the partially
    instantiated TEMPLATE_DECL.  This TI_TEMPLATE change ends up confusing
    modules which decides to stream the logically equivalent TYPE_DECL and
    TEMPLATE_DECL for this partial instantiation separately.

    This patch fixes this by making lookup_template_class dispatch to
    instantiate_alias_template early for alias template specializations.
    In turn we now add such specializations only to the decl table.  This
    admits some nice simplification in the modules code which otherwise has
    to cope with such specializations appearing in both tables.

            PR c++/103994

    gcc/cp/ChangeLog:

            * cp-tree.h (add_mergeable_specialization): Remove second
            parameter.
            * module.cc (depset::disc_bits::DB_ALIAS_TMPL_INST_BIT): Remove.
            (depset::disc_bits::DB_ALIAS_SPEC_BIT): Remove.
            (depset::is_alias_tmpl_inst): Remove.
            (depset::is_alias): Remove.
            (merge_kind::MK_tmpl_alias_mask): Remove.
            (merge_kind::MK_alias_spec): Remove.
            (merge_kind_name): Remove entries for alias specializations.
            (trees_out::core_vals) <case TEMPLATE_DECL>: Adjust after
            removing is_alias_tmpl_inst.
            (trees_in::decl_value): Adjust add_mergeable_specialization
            calls.
            (trees_out::get_merge_kind) <case depset::EK_SPECIALIZATION>:
            Use MK_decl_spec for alias template specializations.
            (trees_out::key_mergeable): Simplify after MK_tmpl_alias_mask
            removal.
            (depset::hash::make_dependency): Adjust after removing
            DB_ALIAS_TMPL_INST_BIT.
            (specialization_add): Don't allow alias templates when !decl_p.
            (depset::hash::add_specializations): Remove now-dead code
            accomodating alias template specializations in the type table.
            * pt.cc (lookup_template_class): Dispatch early to
            instantiate_alias_template for alias templates.  Simplify
            accordingly.
            (add_mergeable_specialization): Remove alias_p parameter and
            simplify accordingly.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr99425-1_b.H: s/alias/decl in dump scan.
            * g++.dg/modules/tpl-alias-1_a.H: Likewise.
            * g++.dg/modules/tpl-alias-2_a.H: New test.
            * g++.dg/modules/tpl-alias-2_b.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment
  2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
                   ` (5 preceding siblings ...)
  2024-03-07 21:39 ` cvs-commit at gcc dot gnu.org
@ 2024-03-07 21:40 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-07 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED

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

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

end of thread, other threads:[~2024-03-07 21:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
2022-10-18 12:59 ` [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment ppalka at gcc dot gnu.org
2023-02-01 17:33 ` Melven.Roehrig-Zoellner at DLR dot de
2024-01-27 16:10 ` ppalka at gcc dot gnu.org
2024-01-27 16:15 ` ppalka at gcc dot gnu.org
2024-03-04 16:02 ` ppalka at gcc dot gnu.org
2024-03-07 21:39 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:40 ` 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).