From cdde52cb3748b1739ee39e419a1ac3bf43e04fc3 Mon Sep 17 00:00:00 2001 From: Razvan Nitu Date: Mon, 11 Sep 2023 14:28:57 +0300 Subject: [PATCH 1/3] Fix Issue 24118 - ICE / regression from 2.103.1 - segfault on CTFE only code in 2.104.2 and 2.105.0 (dlang/dmd!15578) --- dmd/expressionsem.d | 8 +++++--- tests/dmd/compilable/test24118.d | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/dmd/compilable/test24118.d diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 6c21b75dc22..c154cbf306a 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -11013,7 +11013,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor (exp.e2.isStringExp() && (exp.e1.isIntegerExp() || exp.e1.isStringExp()))) return exp; - Identifier hook = global.params.tracegc ? Id._d_arraycatnTXTrace : Id._d_arraycatnTX; + bool useTraceGCHook = global.params.tracegc && sc.needsCodegen(); + + Identifier hook = useTraceGCHook ? Id._d_arraycatnTXTrace : Id._d_arraycatnTX; if (!verifyHookExist(exp.loc, *sc, hook, "concatenating arrays")) { setError(); @@ -11042,7 +11044,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } auto arguments = new Expressions(); - if (global.params.tracegc) + if (useTraceGCHook) { auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); @@ -11069,7 +11071,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor /* `_d_arraycatnTX` canot be used with `-betterC`, but `CatExp`s may be * used with `-betterC`, but only during CTFE. */ - if (global.params.betterC || !sc.needsCodegen()) + if (global.params.betterC) return; if (auto ce = exp.isCatExp()) diff --git a/tests/dmd/compilable/test24118.d b/tests/dmd/compilable/test24118.d new file mode 100644 index 00000000000..25376b73b18 --- /dev/null +++ b/tests/dmd/compilable/test24118.d @@ -0,0 +1,15 @@ +// https://issues.dlang.org/show_bug.cgi?id=24118 + +void map(alias fun, T)(T[] arr) +{ + fun(arr); +} + + +void foo() +{ + if( __ctfe ) + { + ["a", "b", "c"].map!( a => " " ~ a[0] ); + } +} From 0ba78f4dafb389f64c8fbc5d4fc43515cc199fd6 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 14 Sep 2023 12:39:49 +0100 Subject: [PATCH 2/3] Fix Issue 24144 - [REG2.105] Silent file name index overflow (dlang/dmd!15604) * Print an ICE message for Loc.filename overflows * Increase the Loc size again, raising the file name limit from 64K to 4G but keeping the index indirection from dlang/dmd!15199. The `Loc` size for DMD-as-a-library is 16 bytes then, and 12 bytes otherwise. --- dmd/frontend.h | 10 +++++----- dmd/globals.h | 4 ++-- dmd/location.d | 20 ++++++++++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dmd/frontend.h b/dmd/frontend.h index 7273739898d..4065afabce8 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -379,8 +379,8 @@ struct Loc final { private: uint32_t _linnum; - uint16_t _charnum; - uint16_t fileIndex; + uint32_t _charnum; + uint32_t fileIndex; public: static bool showColumns; static MessageStyle messageStyle; @@ -7019,9 +7019,9 @@ struct UnionExp final private: union __AnonStruct__u { - char exp[25LLU]; + char exp[29LLU]; char integerexp[40LLU]; - char errorexp[25LLU]; + char errorexp[29LLU]; char realexp[48LLU]; char complexexp[64LLU]; char symoffexp[64LLU]; @@ -7030,7 +7030,7 @@ struct UnionExp final char assocarrayliteralexp[48LLU]; char structliteralexp[76LLU]; char compoundliteralexp[40LLU]; - char nullexp[25LLU]; + char nullexp[29LLU]; char dotvarexp[49LLU]; char addrexp[40LLU]; char indexexp[74LLU]; diff --git a/dmd/globals.h b/dmd/globals.h index 93dc4db96df..fd5e04d3538 100644 --- a/dmd/globals.h +++ b/dmd/globals.h @@ -357,8 +357,8 @@ struct Loc { private: unsigned _linnum; - unsigned short _charnum; - unsigned short fileIndex; + unsigned _charnum; + unsigned fileIndex; public: static void set(bool showColumns, MessageStyle messageStyle); diff --git a/dmd/location.d b/dmd/location.d index b2b366130ca..6e69cc33933 100644 --- a/dmd/location.d +++ b/dmd/location.d @@ -38,8 +38,8 @@ debug info etc. struct Loc { private uint _linnum; - private ushort _charnum; - private ushort fileIndex; // index into filenames[], starting from 1 (0 means no filename) + private uint _charnum; + private uint fileIndex; // index into filenames[], starting from 1 (0 means no filename) version (LocOffset) uint fileOffset; /// utf8 code unit index relative to start of file, starting from 0 @@ -67,7 +67,7 @@ nothrow: extern (D) this(const(char)* filename, uint linnum, uint charnum) { this._linnum = linnum; - this._charnum = cast(ushort) charnum; + this._charnum = charnum; this.filename = filename; } @@ -80,7 +80,7 @@ nothrow: /// ditto extern (C++) uint charnum(uint num) @nogc @safe { - return _charnum = cast(ushort) num; + return _charnum = num; } /// line number, starting from 1 @@ -114,8 +114,16 @@ nothrow: { //printf("setting %s\n", name); filenames.push(name); - fileIndex = cast(ushort)filenames.length; - assert(fileIndex); // no overflow + fileIndex = cast(uint)filenames.length; + if (!fileIndex) + { + import dmd.globals : global; + import dmd.errors : error, fatal; + + global.gag = 0; // ensure error message gets printed + error(Loc.initial, "internal compiler error: file name index overflow!"); + fatal(); + } } else fileIndex = 0; From e192ec9139f428912ad09cddd4cca55139f8fc53 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 22 Sep 2023 13:52:43 +0200 Subject: [PATCH 3/3] Bump frontend version & Phobos submodule and add changelog entries --- CHANGELOG.md | 7 ++++++- CMakeLists.txt | 2 +- packaging/dlang-tools_version | 2 +- runtime/phobos | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b9a4220a39..5f6b98cc34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ # LDC master #### Big news -- Frontend, druntime and Phobos are at version [2.105.1+](https://dlang.org/changelog/2.105.0.html). (#4476) +- Frontend, druntime and Phobos are at version [2.105.2](https://dlang.org/changelog/2.105.0.html). (#4476, #4498) +- The Windows installer now supports non-admin installs *without* an explicit `/CURRENTUSER` switch. (#4495) #### Platform support #### Bug fixes +- ImportC: + - Fix `static` linkage. (#4484, 4487) + - Make gcc builtins available. (#4483) + - Apple: Support weird `asm("_" "")` mangling stuff. (#4485, #4486) # LDC 1.34.0 (2023-08-26) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4866d43a54a..5c86891277d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ include(GetLinuxDistribution) set(LDC_VERSION "1.35.0") # May be overridden by git hash tag set(DMDFE_MAJOR_VERSION 2) set(DMDFE_MINOR_VERSION 105) -set(DMDFE_PATCH_VERSION 1) +set(DMDFE_PATCH_VERSION 2) set(DMD_VERSION ${DMDFE_MAJOR_VERSION}.${DMDFE_MINOR_VERSION}.${DMDFE_PATCH_VERSION}) diff --git a/packaging/dlang-tools_version b/packaging/dlang-tools_version index 1f9b2b47b5f..d7b23d710b0 100644 --- a/packaging/dlang-tools_version +++ b/packaging/dlang-tools_version @@ -1 +1 @@ -v2.105.1 \ No newline at end of file +v2.105.2 \ No newline at end of file diff --git a/runtime/phobos b/runtime/phobos index d7f31b03664..a4d814cf4de 160000 --- a/runtime/phobos +++ b/runtime/phobos @@ -1 +1 @@ -Subproject commit d7f31b036640670fc9f8364ad9a21d8be302f132 +Subproject commit a4d814cf4de1420fd4a976810c8ec15caf065498