public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression
@ 2021-07-14 10:44 ensadc at mailnesia dot com
  2021-09-06 11:02 ` [Bug c++/101449] " ensadc at mailnesia dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ensadc at mailnesia dot com @ 2021-07-14 10:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101449
           Summary: [modules] internal compiler error: in
                    cxx_eval_call_expression
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

$ cat str.cpp
export module str;

export struct str {
    constexpr str() {
        ptr = new char[42];
    }
    constexpr ~str() { delete[] ptr; }

    const char* ptr = nullptr;
};

export constexpr str get_str() { return str{}; }

$ cat main.cpp
import str;

int main() {
    str a = get_str();
}

$ g++ -std=c++2b -fmodules-ts str.cpp main.cpp
main.cpp: In function ‘int main()’:
main.cpp:4:21:   in ‘constexpr’ expansion of ‘get_str@str()()’
main.cpp:4:21: internal compiler error: in cxx_eval_call_expression, at
cp/constexpr.c:2742
    4 |     str a = get_str();
      |                     ^
0x652ee9 cxx_eval_call_expression
        ../../gcc/gcc/cp/constexpr.c:2742
0x9e54f1 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.c:6250
0x9e8829 cxx_eval_outermost_constant_expr
        ../../gcc/gcc/cp/constexpr.c:7282
0x9ed921 maybe_constant_value(tree_node*, tree_node*, bool)
        ../../gcc/gcc/cp/constexpr.c:7556
0xa20665 cp_fully_fold(tree_node*)
        ../../gcc/gcc/cp/cp-gimplify.c:2146
0xa207f4 cp_fully_fold(tree_node*)
        ../../gcc/gcc/cp/cp-gimplify.c:2140
0xa207f4 cp_fully_fold_init(tree_node*)
        ../../gcc/gcc/cp/cp-gimplify.c:2167
0xc16e03 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ../../gcc/gcc/cp/typeck2.c:816
0xa3a300 check_initializer
        ../../gcc/gcc/cp/decl.c:7169
0xa5dfd0 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:8103
0xb4a89f cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:22258
0xb2608d cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:14801
0xb27d69 cp_parser_declaration_statement
        ../../gcc/gcc/cp/parser.c:13936
0xb28743 cp_parser_statement
        ../../gcc/gcc/cp/parser.c:12066
0xb2904e cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:12433
0xb29128 cp_parser_compound_statement
        ../../gcc/gcc/cp/parser.c:12382
0xb48ff0 cp_parser_function_body
        ../../gcc/gcc/cp/parser.c:24448
0xb48ff0 cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/gcc/cp/parser.c:24499
0xb49aea cp_parser_function_definition_after_declarator
        ../../gcc/gcc/cp/parser.c:30572
0xb4ac96 cp_parser_function_definition_from_specifiers_and_declarator
        ../../gcc/gcc/cp/parser.c:30488
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] 6+ messages in thread

* [Bug c++/101449] [modules] internal compiler error: in cxx_eval_call_expression
  2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
@ 2021-09-06 11:02 ` ensadc at mailnesia dot com
  2022-10-14 12:54 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ensadc at mailnesia dot com @ 2021-09-06 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from ensadc at mailnesia dot com ---
https://godbolt.org/z/fMr9acG15

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

* [Bug c++/101449] [modules] internal compiler error: in cxx_eval_call_expression
  2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
  2021-09-06 11:02 ` [Bug c++/101449] " ensadc at mailnesia dot com
@ 2022-10-14 12:54 ` ppalka at gcc dot gnu.org
  2022-10-14 12:54 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-14 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johelegp at gmail dot com

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 106430 has been marked as a duplicate of this bug. ***

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

* [Bug c++/101449] [modules] internal compiler error: in cxx_eval_call_expression
  2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
  2021-09-06 11:02 ` [Bug c++/101449] " ensadc at mailnesia dot com
  2022-10-14 12:54 ` ppalka at gcc dot gnu.org
@ 2022-10-14 12:54 ` ppalka at gcc dot gnu.org
  2022-10-17 15:15 ` cvs-commit at gcc dot gnu.org
  2022-10-17 15:16 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-14 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/101449] [modules] internal compiler error: in cxx_eval_call_expression
  2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
                   ` (2 preceding siblings ...)
  2022-10-14 12:54 ` ppalka at gcc dot gnu.org
@ 2022-10-17 15:15 ` cvs-commit at gcc dot gnu.org
  2022-10-17 15:16 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-17 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:3bd5d9a28e1ce4d1615902397b5ad50909839d6d

commit r13-3337-g3bd5d9a28e1ce4d1615902397b5ad50909839d6d
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Oct 17 11:14:36 2022 -0400

    c++ modules: streaming constexpr_fundef [PR101449]

    It looks like we currently avoid streaming the RESULT_DECL and PARM_DECLs
    of a constexpr_fundef entry under the assumption that they're just copies
    of the DECL_RESULT and DECL_ARGUMENTS of the FUNCTION_DECL.  Thus we can
    just make new copies of DECL_RESULT and DECL_ARGUMENTS on stream in rather
    than separately streaming them.

    But the FUNCTION_DECL's DECL_RESULT and DECL_ARGUMENTS eventually get
    genericized, whereas the constexpr_fundef entry consists of a copy of the
    FUNCTION_DECL's pre-GENERIC trees.  And notably during genericization we
    lower invisref parms (which entails changing their TREE_TYPE and setting
    DECL_BY_REFERENCE), the lowered form of which the constexpr evaluator
    doesn't expect to see, and so this copying approach causes us to ICE for
    the below testcase.

    This patch fixes this by faithfully streaming the RESULT_DECL and
    PARM_DECLs of a constexpr_fundef entry, which seems to just work.

    Nathan says[1]: Hm, the reason for the complexity was that I wanted to
    recreate the tree graph where the fndecl came from one TU and the defn
    came from another one -- we need the definition to refer to argument
    decls from the already-read decl.  However, it seems that for constexpr
    fns here, that is not needed, resulting in a significant simplification.

    [1]: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603662.html

            PR c++/101449

    gcc/cp/ChangeLog:

            * module.cc (trees_out::write_function_def): Stream the
            parms and result of the constexpr_fundef entry.
            (trees_in::read_function_def): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/cexpr-3_a.C: New test.
            * g++.dg/modules/cexpr-3_b.C: New test.

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

* [Bug c++/101449] [modules] internal compiler error: in cxx_eval_call_expression
  2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
                   ` (3 preceding siblings ...)
  2022-10-17 15:15 ` cvs-commit at gcc dot gnu.org
@ 2022-10-17 15:16 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-17 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk.

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

end of thread, other threads:[~2022-10-17 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 10:44 [Bug c++/101449] New: [modules] internal compiler error: in cxx_eval_call_expression ensadc at mailnesia dot com
2021-09-06 11:02 ` [Bug c++/101449] " ensadc at mailnesia dot com
2022-10-14 12:54 ` ppalka at gcc dot gnu.org
2022-10-14 12:54 ` ppalka at gcc dot gnu.org
2022-10-17 15:15 ` cvs-commit at gcc dot gnu.org
2022-10-17 15:16 ` 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).