Bug 113125 - [D] internal compiler error: in make_import, at d/imports.cc:48
Summary: [D] internal compiler error: in make_import, at d/imports.cc:48
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: 13.2.0
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2023-12-24 02:55 UTC by Witold Baryluk
Modified: 2024-03-03 00:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Witold Baryluk 2023-12-24 02:55:19 UTC
Debian testing, amd64, gcc version 13.2.0 (Debian 13.2.0-7) 


meta.d:

```
module objc.meta;
struct A;
```


runtime.d:

```
module objc.runtime;
public import meta : A;
```


gdc -v -c -I. runtime.d

```
$ gdc -v -c -I. runtime.d 
Using built-in specs.
COLLECT_GCC=gdc
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-7' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-13-13.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-13-13.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=3
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Debian 13.2.0-7) 
COLLECT_GCC_OPTIONS='-v' '-c' '-I' '.' '-o' 'runtime.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-linux-gnu/13/d21 runtime.d -quiet -dumpbase runtime.d -dumpbase-ext .d -mtune=generic -march=x86-64 -version -imultiarch x86_64-linux-gnu -I . -v -o /tmp/ccPyiN0m.s
GNU D (Debian 13.2.0-7) version 13.2.0 (x86_64-linux-gnu)
	compiled by GNU C version 13.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
binary    /usr/libexec/gcc/x86_64-linux-gnu/13/d21
version   v2.103.1

predefs   GNU D_Version2 LittleEndian GNU_DWARF2_Exceptions GNU_StackGrowsDown GNU_InlineAsm D_LP64 D_PIC D_PIE assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo all X86_64 D_HardFloat Posix linux CRuntime_Glibc CppRuntime_Gcc
parse     runtime
importall runtime
import    meta	(meta.d)
import    object	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/object.d)
import    core.attribute	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/attribute.d)
import    gcc.attributes	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/gcc/attributes.d)
import    core.internal.hash	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/hash.d)
import    core.internal.traits	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/traits.d)
import    core.internal.entrypoint	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/entrypoint.d)
import    core.internal.array.appending	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/appending.d)
import    core.internal.array.comparison	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/comparison.d)
import    core.internal.array.equality	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/equality.d)
import    core.internal.array.casting	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/casting.d)
import    core.internal.array.concatenation	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/concatenation.d)
import    core.internal.array.construction	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/construction.d)
import    core.internal.array.arrayassign	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/arrayassign.d)
import    core.internal.array.capacity	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/array/capacity.d)
import    core.internal.dassert	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/dassert.d)
import    core.atomic	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/atomic.d)
import    core.internal.attributes	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/attributes.d)
import    core.internal.atomic	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/atomic.d)
import    gcc.builtins	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/gcc/builtins.d)
import    gcc.config	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/gcc/config.d)
import    core.internal.destruction	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/destruction.d)
import    core.internal.moving	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/moving.d)
import    core.internal.postblit	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/postblit.d)
import    core.internal.switch_	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/internal/switch_.d)
import    core.lifetime	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/lifetime.d)
import    core.builtins	(/usr/lib/gcc/x86_64-linux-gnu/13/include/d/core/builtins.d)
semantic  runtime
semantic2 runtime
semantic3 runtime
code      runtime
runtime.d:2:15: internal compiler error: in make_import, at d/imports.cc:48
    2 | public import meta : A;
      |               ^
0x7fc5daa6f6c9 __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7fc5daa6f784 __libc_start_main_impl
	../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions.

```


No issues with ldc2 or dmd.

godbolt - https://godbolt.org/z/n5s9njMvd


Issue extracted from https://github.com/MrcSnm/D-objective-c  (branch main, tag v1.0.11, commit b0c09e1913910b298659cad22985338bbfa27251 ), as reported in https://github.com/MrcSnm/HipremeEngine/issues/98#issue-2054859070
Comment 1 GCC Commits 2024-02-12 16:08:40 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

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

commit r14-8935-gb0efb1c35724e3332ee5993976efb98200c1a154
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 12 16:59:12 2024 +0100

    d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]
    
    The cause of the ICE was that TYPE_DECLs were only being generated for
    structs with members, not opaque structs.
    
            PR d/113125
    
    gcc/d/ChangeLog:
    
            * types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
            apply UDAs to opaque struct declarations.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr113125.d: New test.
            * gdc.dg/pr113125.d: New test.
Comment 2 GCC Commits 2024-03-03 00:00:51 UTC
The releases/gcc-13 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:341fa4d2340b21c322082fb5a7cad18a48b9eda7

commit r13-8398-g341fa4d2340b21c322082fb5a7cad18a48b9eda7
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 12 16:59:12 2024 +0100

    d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]
    
    The cause of the ICE was that TYPE_DECLs were only being generated for
    structs with members, not opaque structs.
    
            PR d/113125
    
    gcc/d/ChangeLog:
    
            * types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
            apply UDAs to opaque struct declarations.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr113125.d: New test.
            * gdc.dg/pr113125.d: New test.
    
    (cherry picked from commit b0efb1c35724e3332ee5993976efb98200c1a154)
Comment 3 GCC Commits 2024-03-03 00:04:09 UTC
The releases/gcc-12 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

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

commit r12-10188-gf3567889645ce1fed79c13d644313aa2a8ab9318
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 12 16:59:12 2024 +0100

    d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]
    
    The cause of the ICE was that TYPE_DECLs were only being generated for
    structs with members, not opaque structs.
    
            PR d/113125
    
    gcc/d/ChangeLog:
    
            * types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
            apply UDAs to opaque struct declarations.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr113125.d: New test.
            * gdc.dg/pr113125.d: New test.
    
    (cherry picked from commit b0efb1c35724e3332ee5993976efb98200c1a154)
Comment 4 GCC Commits 2024-03-03 00:09:01 UTC
The releases/gcc-11 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:3c0c18799eff99221d2eaae3de6fca6da14269dd

commit r11-11263-g3c0c18799eff99221d2eaae3de6fca6da14269dd
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 12 16:59:12 2024 +0100

    d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]
    
    The cause of the ICE was that TYPE_DECLs were only being generated for
    structs with members, not opaque structs.
    
            PR d/113125
    
    gcc/d/ChangeLog:
    
            * types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
            apply UDAs to opaque struct declarations.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr113125.d: New test.
            * gdc.dg/pr113125.d: New test.
    
    (cherry picked from commit b0efb1c35724e3332ee5993976efb98200c1a154)
Comment 5 Iain Buclaw 2024-03-03 00:13:27 UTC
Fixed and backported.