public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/108877] New: Explicit immutable struct import internal compiler error
@ 2023-02-21 20:04 belka at caraus dot de
  2023-02-26  0:17 ` [Bug d/108877] " ibuclaw at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: belka at caraus dot de @ 2023-02-21 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108877
           Summary: Explicit immutable struct import internal compiler
                    error
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: belka at caraus dot de
  Target Milestone: ---

We have 2 files. util/Version.d:

```
module util.Version;

immutable struct Ver
{
}
```
and the main file:

```
import util.Version : Ver;
```

Compiling with „gdc-12 -c util/Version.d version_test.d“ results in the error:

> version_test.d:1:8: internal compiler error: in make_import, at d/imports.cc:48
>     1 | import util.Version : Ver;
>       |        ^
> 0x1bc1e87 internal_error(char const*, ...)
> 	???:0
> 0x7d27f3 fancy_abort(char const*, int, char const*)
> 	???:0
> 0x9d4214 ImportVisitor::visit(AggregateDeclaration*)
> 	???:0
> 0x9d3cfe build_import_decl(Dsymbol*)
> 	???:0
> 0x9ca0ff DeclVisitor::visit(Import*)
> 	???:0
> 0x9c70a6 build_decl_tree(Dsymbol*)
> 	???:0
> 0x9d6fc0 build_module_tree(Module*)
> 	???:0
> 0x9c9f4b DeclVisitor::visit(Module*)
> 	???:0
> 0x9c70a6 build_decl_tree(Dsymbol*)
> 	???: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.

This is reproducable with gdc-12.2.0 and gdc 11.2.0. GDC 12.2.0 info:

> gdc-12 -v
> Using built-in specs.
> COLLECT_GCC=gdc-12
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/12/lto-wrapper
> Target: x86_64-slackware-linux
> Configured with: ../gcc-12.2.0/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --disable-bootstrap --enable-languages=c,c++,d --enable-threads=posix --enable-checking=release --with-system-zlib --disable-libquadmath-support --with-default-libstdcxx-abi=new --disable-libstdcxx-pch --disable-libunwind-exceptions --enable-__cxa_atexit --disable-libssp --enable-gnu-unique-object --enable-plugin --enable-lto --disable-install-libiberty --disable-werror --with-gcc-major-version-only --with-isl --program-suffix=-12 --with-arch-directory=amd64 --disable-gtktest --enable-clocale=gnu --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
> Thread model: posix
> Supported LTO compression algorithms: zlib zstd
> gcc version 12.2.0 (GCC)

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
@ 2023-02-26  0:17 ` ibuclaw at gcc dot gnu.org
  2023-02-27 12:39 ` belka at caraus dot de
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-02-26  0:17 UTC (permalink / raw)
  To: gcc-bugs

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

ibuclaw at gcc dot gnu.org changed:

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

--- Comment #1 from ibuclaw at gcc dot gnu.org ---
Immutable is the keyword here. Stub debug symbols are only attached to the main
variant of a type.  I think this would also be reproducible with `immutable
class` and `immutable enum` as well.

Have fix really to commit and backport once I test it.

---

diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index 3b46d1b7560..2efef4ed54f 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -106,12 +106,16 @@ public:
     tree type = build_ctype (d->type);
     /* Not all kinds of D enums create a TYPE_DECL.  */
     if (TREE_CODE (type) == ENUMERAL_TYPE)
-      this->result_ = this->make_import (TYPE_STUB_DECL (type));
+      {
+       type = TYPE_MAIN_VARIANT (type);
+       this->result_ = this->make_import (TYPE_STUB_DECL (type));
+      }
   }

   void visit (AggregateDeclaration *d) final override
   {
     tree type = build_ctype (d->type);
+    type = TYPE_MAIN_VARIANT (type);
     this->result_ = this->make_import (TYPE_STUB_DECL (type));
   }

@@ -119,6 +123,7 @@ public:
   {
     /* Want the RECORD_TYPE, not POINTER_TYPE.  */
     tree type = TREE_TYPE (build_ctype (d->type));
+    type = TYPE_MAIN_VARIANT (type);
     this->result_ = this->make_import (TYPE_STUB_DECL (type));
   }

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
  2023-02-26  0:17 ` [Bug d/108877] " ibuclaw at gcc dot gnu.org
@ 2023-02-27 12:39 ` belka at caraus dot de
  2023-03-03  0:26 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: belka at caraus dot de @ 2023-02-27 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Eugen Wissner <belka at caraus dot de> ---
Not sure about class and enum, but „const struct“ results in a similar error.

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
  2023-02-26  0:17 ` [Bug d/108877] " ibuclaw at gcc dot gnu.org
  2023-02-27 12:39 ` belka at caraus dot de
@ 2023-03-03  0:26 ` cvs-commit at gcc dot gnu.org
  2023-03-03  2:28 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-03  0:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:ce1cea3e22f58bbddde017f8a92e59bae8892339

commit r13-6432-gce1cea3e22f58bbddde017f8a92e59bae8892339
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 27 20:46:18 2023 +0100

    d: Fix ICE on explicit immutable struct import [PR108877]

    Const and immutable types are built as variants of the type they are
    derived from, and TYPE_STUB_DECL is not set for these variants.

            PR d/108877

    gcc/d/ChangeLog:

            * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
            make_import on TYPE_MAIN_VARIANT.
            (ImportVisitor::visit (AggregateDeclaration *)): Likewise.
            (ImportVisitor::visit (ClassDeclaration *)): Likewise.

    gcc/testsuite/ChangeLog:

            * gdc.dg/imports/pr108877a.d: New test.
            * gdc.dg/pr108877.d: New test.

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
                   ` (2 preceding siblings ...)
  2023-03-03  0:26 ` cvs-commit at gcc dot gnu.org
@ 2023-03-03  2:28 ` cvs-commit at gcc dot gnu.org
  2023-03-03  2:33 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-03  2:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:2583365912c8700abe1f4a23ed611acb80fac09d

commit r12-9212-g2583365912c8700abe1f4a23ed611acb80fac09d
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 27 20:46:18 2023 +0100

    d: Fix ICE on explicit immutable struct import [PR108877]

    Const and immutable types are built as variants of the type they are
    derived from, and TYPE_STUB_DECL is not set for these variants.

            PR d/108877

    gcc/d/ChangeLog:

            * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
            make_import on TYPE_MAIN_VARIANT.
            (ImportVisitor::visit (AggregateDeclaration *)): Likewise.
            (ImportVisitor::visit (ClassDeclaration *)): Likewise.

    gcc/testsuite/ChangeLog:

            * gdc.dg/imports/pr108877a.d: New test.
            * gdc.dg/pr108877.d: New test.

    (cherry picked from commit ce1cea3e22f58bbddde017f8a92e59bae8892339)

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
                   ` (3 preceding siblings ...)
  2023-03-03  2:28 ` cvs-commit at gcc dot gnu.org
@ 2023-03-03  2:33 ` cvs-commit at gcc dot gnu.org
  2023-03-03  2:43 ` cvs-commit at gcc dot gnu.org
  2023-03-03  2:46 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-03  2:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:fe6cd1ba23ecbce9c0206c08db182cb5164e3b7d

commit r11-10554-gfe6cd1ba23ecbce9c0206c08db182cb5164e3b7d
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 27 20:46:18 2023 +0100

    d: Fix ICE on explicit immutable struct import [PR108877]

    Const and immutable types are built as variants of the type they are
    derived from, and TYPE_STUB_DECL is not set for these variants.

            PR d/108877

    gcc/d/ChangeLog:

            * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
            make_import on TYPE_MAIN_VARIANT.
            (ImportVisitor::visit (AggregateDeclaration *)): Likewise.
            (ImportVisitor::visit (ClassDeclaration *)): Likewise.

    gcc/testsuite/ChangeLog:

            * gdc.dg/imports/pr108877a.d: New test.
            * gdc.dg/pr108877.d: New test.

    (cherry picked from commit ce1cea3e22f58bbddde017f8a92e59bae8892339)

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
                   ` (4 preceding siblings ...)
  2023-03-03  2:33 ` cvs-commit at gcc dot gnu.org
@ 2023-03-03  2:43 ` cvs-commit at gcc dot gnu.org
  2023-03-03  2:46 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-03  2:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:c90e68bffa37edd655dd2f5d14bb7b213c9e2431

commit r10-11235-gc90e68bffa37edd655dd2f5d14bb7b213c9e2431
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 27 20:46:18 2023 +0100

    d: Fix ICE on explicit immutable struct import [PR108877]

    Const and immutable types are built as variants of the type they are
    derived from, and TYPE_STUB_DECL is not set for these variants.

            PR d/108877

    gcc/d/ChangeLog:

            * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
            make_import on TYPE_MAIN_VARIANT.
            (ImportVisitor::visit (AggregateDeclaration *)): Likewise.
            (ImportVisitor::visit (ClassDeclaration *)): Likewise.

    gcc/testsuite/ChangeLog:

            * gdc.dg/imports/pr108877a.d: New test.
            * gdc.dg/pr108877.d: New test.

    (cherry picked from commit ce1cea3e22f58bbddde017f8a92e59bae8892339)

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

* [Bug d/108877] Explicit immutable struct import internal compiler error
  2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
                   ` (5 preceding siblings ...)
  2023-03-03  2:43 ` cvs-commit at gcc dot gnu.org
@ 2023-03-03  2:46 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-03-03  2:46 UTC (permalink / raw)
  To: gcc-bugs

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

ibuclaw at gcc dot gnu.org changed:

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

--- Comment #7 from ibuclaw at gcc dot gnu.org ---
Fix committed and backported.

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

end of thread, other threads:[~2023-03-03  2:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 20:04 [Bug d/108877] New: Explicit immutable struct import internal compiler error belka at caraus dot de
2023-02-26  0:17 ` [Bug d/108877] " ibuclaw at gcc dot gnu.org
2023-02-27 12:39 ` belka at caraus dot de
2023-03-03  0:26 ` cvs-commit at gcc dot gnu.org
2023-03-03  2:28 ` cvs-commit at gcc dot gnu.org
2023-03-03  2:33 ` cvs-commit at gcc dot gnu.org
2023-03-03  2:43 ` cvs-commit at gcc dot gnu.org
2023-03-03  2:46 ` ibuclaw 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).