From 985f64ba03ad2b5e210e8e555c6e59253188faaa Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 22 Feb 2024 09:34:23 +0100 Subject: [PATCH] Fix Bugzilla 24399 - Link failure on MacOS with address=0x0 points to section(2) with no content --- compiler/src/dmd/todt.d | 5 +++++ compiler/test/compilable/issue24399.d | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 compiler/test/compilable/issue24399.d diff --git a/compiler/src/dmd/todt.d b/compiler/src/dmd/todt.d index ca73e1e570..1b9aa8f957 100644 --- a/compiler/src/dmd/todt.d +++ b/compiler/src/dmd/todt.d @@ -92,6 +92,11 @@ extern (C++) void Initializer_toDt(Initializer init, ref DtBuilder dtb, bool isC if (tb.ty == Tvector) tb = (cast(TypeVector)tb).basetype; + if (ai.dim == 0 && tb.isZeroInit(ai.loc)) + { + dtb.nzeros(cast(uint)ai.type.size()); + return; + } Type tn = tb.nextOf().toBasetype(); //printf("\tdim = %d\n", ai.dim); diff --git a/compiler/test/compilable/issue24399.d b/compiler/test/compilable/issue24399.d new file mode 100644 index 0000000000..ae3e7442f5 --- /dev/null +++ b/compiler/test/compilable/issue24399.d @@ -0,0 +1,9 @@ +// REQUIRED_ARGS: -main +// LINK: +template rt_options() +{ + __gshared string[] rt_options = []; + string[] rt_options_tls = []; +} + +alias _ = rt_options!();