Skip to content

Commit 42e75e5

Browse files
authored
Fix dlang#23166 Set sc3.minst to root module (dlang#23169)
1 parent 2a9702f commit 42e75e5

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

compiler/src/dmd/semantic3.d

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,12 @@ void semanticRTInfo(AggregateDeclaration ad)
18601860
auto sc = ad.rtInfoScope;
18611861
Scope* sc3 = ti.tempdecl._scope.startCTFE();
18621862
sc3.tinst = sc.tinst;
1863-
sc3.minst = sc.minst;
1863+
// Use the root module so nested RTInfoImpl instances get codegen'd.
1864+
// If rtInfoScope comes from a non-root ImportC module whose minst is that
1865+
// module itself (see scopeCreateGlobal), so needsCodegen() would skip
1866+
// RTInfoImpl even though TypeInfo references it at link time.
1867+
// See https://github.com/dlang/dmd/issues/23166.
1868+
sc3.minst = sc._module.importedFrom;
18641869
if (ad.isDeprecated())
18651870
sc3.stc |= STC.deprecated_;
18661871

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Minified from <aws/s3/s3_client.h>
2+
3+
struct MyFoo {
4+
};
5+
6+
typedef struct MyFoo *(MyFuncPtr)(struct MyFoo *allocator);
7+
8+
struct BrokenStruct {
9+
const struct MyFoo *network_interface_names_array;
10+
int num_network_interface_names;
11+
MyFuncPtr *buffer_pool_factory_fn;
12+
void *buffer_pool_user_data;
13+
};

compiler/test/runnable/test23166.d

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://github.com/dlang/dmd/issues/23166
2+
3+
import imports.imp23166;
4+
5+
void main()
6+
{
7+
auto s = new BrokenStruct();
8+
assert(s !is null);
9+
}

0 commit comments

Comments
 (0)