public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
@ 2024-04-21 14:38 porten at kde dot org
  2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-21 14:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114795
           Summary: internal compiler error: in finish_member_declaration
                    after module import in gcc 14.0.1 snapshot
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: porten at kde dot org
  Target Milestone: ---

This is with a gcc/g++ build created locally from the published snapshot
package gcc-14-20240414.tar.xz.

---------- compiler info ----------
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/gcc-14/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/porten/tmp/gcc-14-20240414/configure --disable-multilib
--prefix=/opt/gcc-14 --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240414 (experimental) (GCC)

---------- Command triggering the bug ----------

g++ -std=c++2a -fmodules-ts -c url.cpp queue.cpp

---------- url.cpp ----------

module;

#include <chrono>

export module url;

---------- queue.cpp ----------

import url;

#include <format>

---------- output -------------

In file included from /opt/gcc-14/include/c++/14.0.1/concepts:46,
                 from /opt/gcc-14/include/c++/14.0.1/compare:40,
                 from /opt/gcc-14/include/c++/14.0.1/array:38,
                 from /opt/gcc-14/include/c++/14.0.1/format:43,
                 from queue.cpp:3:
/opt/gcc-14/include/c++/14.0.1/type_traits:89:36: error: template definition of
non-template ‘constexpr const _Tp std::integral_constant<_Tp, __v>::value’
   89 |       static constexpr _Tp value = __v;
      |                                    ^~~
[ ... 7000 lines with compiler errors ... ]
/opt/gcc-14/include/c++/14.0.1/optional:265:30: internal compiler error: in
finish_member_declaration, at cp/semantics.cc:3840
  265 |       _Storage<_Stored_type> _M_payload;
      |                              ^~~~~~~~~~
0x7fa7e1 finish_member_declaration(tree_node*)
        /home/porten/tmp/gcc-14-20240414/gcc/cp/semantics.cc:3840
0xc28be5 cp_parser_member_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:28497
0xbeef63 cp_parser_member_specification_opt
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:27840
0xbeef63 cp_parser_class_specifier
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:26845
0xbeef63 cp_parser_type_specifier
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:20064
0xbf094d cp_parser_decl_specifier_seq
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:16590
0xc25cfa cp_parser_single_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:33143
0xc2619c cp_parser_template_declaration_after_parameters
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:32799
0xc26a80 cp_parser_explicit_template_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:33072
0xc2b599 cp_parser_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:15502
0xc29c99 cp_parser_toplevel_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:15594
0xc29c99 cp_parser_declaration_seq_opt
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:15345
0xc2a13b cp_parser_namespace_body
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:22128
0xc2a13b cp_parser_namespace_definition
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:22106
0xc2b896 cp_parser_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:15553
0xc2bf8a cp_parser_toplevel_declaration
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:15594
0xc2bf8a cp_parser_translation_unit
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:5279
0xc2bf8a c_parse_file()
        /home/porten/tmp/gcc-14-20240414/gcc/cp/parser.cc:51268
0xd7ae41 c_common_parse_file()
        /home/porten/tmp/gcc-14-20240414/gcc/c-family/c-opts.cc:1311
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.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
@ 2024-04-21 22:17 ` porten at kde dot org
  2024-04-22  0:20 ` porten at kde dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-21 22:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from porten at kde dot org ---
Looking through the other c++-modules reports, I saw that someone reduced a
similar test case to an ICE in comment #3:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114600#c3  Therefore this bug
could be a duplicate of #114600.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
  2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
@ 2024-04-22  0:20 ` porten at kde dot org
  2024-04-22  1:52 ` nshead at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22  0:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from porten at kde dot org ---
The ICE is still there with current master
(f17d31e709af9b2d488adecd6cd040dfc1f23b04). The test case provided in bug
#114600 works for me now, though. So similar but seemingly no duplicate after
all.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
  2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
  2024-04-22  0:20 ` porten at kde dot org
@ 2024-04-22  1:52 ` nshead at gcc dot gnu.org
  2024-04-22  7:37 ` porten at kde dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-22  1:52 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=114600,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=99000
                 CC|                            |nshead at gcc dot gnu.org

--- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Similarly to PR114600 (and PR99000 and maybe some others?) this is because we
don't support textual redefinitions yet (`#include` after `import` naming the
same things). See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Modules.html:


G++’s modules support is not complete. Other than bugs, the known missing
pieces are: 

[...]

Textual merging of reachable GM entities

    Entities may be multiply defined across different header-units. These must
be de-duplicated, and this is implemented across imports, or when an import
redefines a textually-defined entity. However the reverse is not
implemented—textually redefining an entity that has been defined in an imported
header-unit. A redefinition error is emitted.


A workaround is to ensure that `#include` always goes before `import`, or to
use a header module here rather than `#include`.

FWIW this particular ICE is because we hit this assertion:

  /* Don't add decls after definition.  */
  gcc_assert (TYPE_BEING_DEFINED (current_class_type)
              /* We can add lambda types when late parsing default
                 arguments.  */
              || LAMBDA_TYPE_P (TREE_TYPE (decl)));

but the class has already been defined earlier, by the import.


The other issue here is that we didn't discard the entire GMF here, I suppose
possibly because of a similar issue as described in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114630#c2.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (2 preceding siblings ...)
  2024-04-22  1:52 ` nshead at gcc dot gnu.org
@ 2024-04-22  7:37 ` porten at kde dot org
  2024-04-22  8:51 ` nshead at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from porten at kde dot org ---
Thanks for the reminder about the workaround. I had once seen it before trying
module but did not see the relation when running into problems later.  In the
small test case, reordering the import and includes helps! It is just that the
original code base exposes another problem. In fact, the original one I
experienced:

/opt/gcc-14/include/c++/14.0.1/format: In member function ‘auto
std::__format::_Sink_iter<_CharT>::_M_reserve(std::size_t) const [with _CharT =
char]’:
/opt/gcc-14/include/c++/14.0.1/format:2632:7: error: invalid conversion in
return statement
 2632 |       _M_reserve(size_t __n) const
      |       ^~~~~~~~~~
<<< Unknown tree: template_type_parm >>>

struct _Reservation

return D.267932;
/opt/gcc-14/include/c++/14.0.1/format:2632:7: internal compiler error:
‘verify_gimple’ failed
0x138b51e verify_gimple_in_seq(gimple*, bool)
        /home/porten/git/gcc/gcc/tree-cfg.cc:5318
[...]


If of any interest, I can try to reduce a test case preserving the error.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (3 preceding siblings ...)
  2024-04-22  7:37 ` porten at kde dot org
@ 2024-04-22  8:51 ` nshead at gcc dot gnu.org
  2024-04-22 22:49 ` porten at kde dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-22  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Thanks! That error message looks new to me, if you have a reproduction that
would be great.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (4 preceding siblings ...)
  2024-04-22  8:51 ` nshead at gcc dot gnu.org
@ 2024-04-22 22:49 ` porten at kde dot org
  2024-04-23 16:14 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22 22:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from porten at kde dot org ---
The test case for the other ICE is quite similar to the first one:

------------- command ------------

g++ -std=c++2a -fmodules-ts -c url.cpp queue.cpp

----------- url.cp ---------------

module;

#include <chrono>

export module url;

----------- queue.cpp -------------

#include <chrono>

import url;

#include <format>

void foo() { (void)std::format("bar"); }

--------- output --------------

In file included from /opt/gcc-14/include/c++/14.0.1/bits/chrono_io.h:39,
                 from /opt/gcc-14/include/c++/14.0.1/chrono:3360,
                 from queue.cpp:1:
/opt/gcc-14/include/c++/14.0.1/format: In member function ‘auto
std::__format::_Sink_iter<_CharT>::_M_reserve(std::size_t) const [with _CharT =
char]’:
/opt/gcc-14/include/c++/14.0.1/format:2632:7: error: invalid conversion in
return statement
 2632 |       _M_reserve(size_t __n) const
      |       ^~~~~~~~~~
<<< Unknown tree: template_type_parm >>>

struct _Reservation

return D.207483;
/opt/gcc-14/include/c++/14.0.1/format:2632:7: internal compiler error:
‘verify_gimple’ failed
0x138b51e verify_gimple_in_seq(gimple*, bool)
        /home/porten/git/gcc/gcc/tree-cfg.cc:5318
0x10226ba gimplify_body(tree_node*, bool)
        /home/porten/git/gcc/gcc/gimplify.cc:19234
0x1022876 gimplify_function_tree(tree_node*)
        /home/porten/git/gcc/gcc/gimplify.cc:19352
0xe42f17 cgraph_node::analyze()
        /home/porten/git/gcc/gcc/cgraphunit.cc:687
0xe45a77 analyze_functions
        /home/porten/git/gcc/gcc/cgraphunit.cc:1251
0xe469fd symbol_table::finalize_compilation_unit()
        /home/porten/git/gcc/gcc/cgraphunit.cc:2560

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (5 preceding siblings ...)
  2024-04-22 22:49 ` porten at kde dot org
@ 2024-04-23 16:14 ` ppalka at gcc dot gnu.org
  2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-23 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-23
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reduced version of comment #6 testcase:

$ cat 114795_a.H
template<class T>
struct A {
  auto f() { return 0; }
};

template<class T>
inline void g() {
  A<int> a;
  a.f();
}

$ cat 114795_b.C
template<class T>
struct A {
  auto f() { return 0; }
};

A<int> a;

import "114795_a.H";

int main() {
  g<int>();
}

$ g++ -fmodules-ts 114795_*
In module ./114795-2_a.H, imported at 114795_b.C:8:
114795_a.H: In instantiation of ‘void g() [with T = int]’:
114795_b.C:11:9:   required from here
   11 |   g<int>();
      |   ~~~~~~^~
114795_a.H:9:6: error: use of ‘auto A<T>::f() [with T = int]’ before deduction
of ‘auto’
    9 |   a.f();
      |   ~~~^~
114795_a.H:9:6: error: use of ‘auto A<T>::f() [with T = int]’ before deduction
of ‘auto’


I think I have a fix -- we need to propagate an already-deduced return type
during deduplication.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (6 preceding siblings ...)
  2024-04-23 16:14 ` ppalka at gcc dot gnu.org
@ 2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
  2024-04-23 18:09 ` ppalka at gcc dot gnu.org
  2024-04-24  7:15 ` porten at kde dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-23 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:4f9401d1a802325e5dfa2db841945e1a9c59a980

commit r14-10096-g4f9401d1a802325e5dfa2db841945e1a9c59a980
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Apr 23 14:01:22 2024 -0400

    c++/modules: deduced return type merging [PR114795]

    When merging an imported function template specialization with an
    existing one, if the existing one has an undeduced return type and the
    imported one's is already deduced, we need to propagate the deduced type
    since once we install the imported definition we won't get a chance to
    deduce it by normal means.

    So this patch makes is_matching_decl propagate the deduced return
    type alongside our propagation of the exception specification.
    Another option would be to propagate it later when installing the
    imported definition from read_function_def, but it seems preferable
    to do it sooner rather than later.

            PR c++/114795

    gcc/cp/ChangeLog:

            * module.cc (trees_in::is_matching_decl): Propagate deduced
            function return type.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/auto-4_a.H: New test.
            * g++.dg/modules/auto-4_b.C: New test.

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

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (7 preceding siblings ...)
  2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
@ 2024-04-23 18:09 ` ppalka at gcc dot gnu.org
  2024-04-24  7:15 ` porten at kde dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-23 18:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The "invalid conversion in return statement" error should hopefully be fixed
now.

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

* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
  2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
                   ` (8 preceding siblings ...)
  2024-04-23 18:09 ` ppalka at gcc dot gnu.org
@ 2024-04-24  7:15 ` porten at kde dot org
  9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-24  7:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from porten at kde dot org ---
It is! Even my original code base now fully compiles without errors. Thank you!

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

end of thread, other threads:[~2024-04-24  7:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
2024-04-22  0:20 ` porten at kde dot org
2024-04-22  1:52 ` nshead at gcc dot gnu.org
2024-04-22  7:37 ` porten at kde dot org
2024-04-22  8:51 ` nshead at gcc dot gnu.org
2024-04-22 22:49 ` porten at kde dot org
2024-04-23 16:14 ` ppalka at gcc dot gnu.org
2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
2024-04-23 18:09 ` ppalka at gcc dot gnu.org
2024-04-24  7:15 ` porten at kde dot 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).