From 95216db6deb1b39d6bd91f01e8b38772fbe7629b Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 24 Oct 2024 04:01:19 -0700 Subject: [PATCH 1/5] fix bugzilla Issue 24819 - Optimizer changes result of float calculations on 32-bit (dlang/dmd!17023) (cherry picked from commit 8b9b481a322bdcbfdad38ba4ad74182742aef118) --- tests/dmd/runnable/test24819.d | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/dmd/runnable/test24819.d diff --git a/tests/dmd/runnable/test24819.d b/tests/dmd/runnable/test24819.d new file mode 100644 index 0000000000..3ba374bed3 --- /dev/null +++ b/tests/dmd/runnable/test24819.d @@ -0,0 +1,18 @@ +import core.stdc.stdio; + +pragma(inline, true) +double sqrt(double x) +{ + static import core.math; + return core.math.sqrt(x); +} + +int main() +{ + double q = -5.0; + double r = q + 1.0; + double result = sqrt(-r); + //printf("%f\n", result); + assert(result == 2); + return 0; +} From e34b32dac3eeeb194d8387918b3362eedb08aa1a Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Sat, 2 Nov 2024 19:54:47 +1300 Subject: [PATCH 2/5] Fix bugzilla issue 24841 - UTF-16 surrogates when used as an escape of a string should hint on error --- dmd/lexer.d | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/dmd/lexer.d b/dmd/lexer.d index 26a56c2b1f..487076ea5f 100644 --- a/dmd/lexer.d +++ b/dmd/lexer.d @@ -1556,6 +1556,8 @@ class Lexer if (ndigits != 2 && !utf_isValidDchar(v)) { error(loc, "invalid UTF character \\U%08x", v); + if (v >= 0xD800 && v <= 0xDFFF) + errorSupplemental("The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?"); v = '?'; // recover with valid UTF character } } @@ -3169,6 +3171,11 @@ class Lexer eSink.error(loc, format, args); } + void errorSupplemental(T...)(const(char)* format, T args) + { + eSink.errorSupplemental(token.loc, format, args); + } + void deprecation(T...)(const ref Loc loc, const(char)* format, T args) { eSink.deprecation(loc, format, args); @@ -3672,6 +3679,7 @@ unittest import core.stdc.stdarg; string expected; + string expectedSupplemental; bool gotError; void error(const ref Loc loc, const(char)* format, ...) @@ -3684,13 +3692,25 @@ unittest va_end(ap); assert(expected == actual); } + + void errorSupplemental(const ref Loc loc, const(char)* format, ...) + { + gotError = true; + char[128] buffer = void; + va_list ap; + va_start(ap, format); + auto actual = buffer[0 .. vsnprintf(buffer.ptr, buffer.length, format, ap)]; + va_end(ap); + assert(expectedSupplemental == actual); + } } ErrorSinkTest errorSink = new ErrorSinkTest; - void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false) + void test2(string sequence, string[2] expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false) { - errorSink.expected = expectedError; + errorSink.expected = expectedError[0]; + errorSink.expectedSupplemental = expectedError[1]; errorSink.gotError = false; auto p = cast(const(char)*)sequence.ptr; Lexer lexer = new Lexer(errorSink); @@ -3703,6 +3723,11 @@ unittest assert(expectedScanLength == actualScanLength); } + void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false) + { + test2(sequence, [expectedError, null], expectedReturnValue, expectedScanLength, Ccompile); + } + test("c", `undefined escape sequence \c`, 'c', 1); test("!", `undefined escape sequence \!`, '!', 1); test(""", `undefined escape sequence \&`, '&', 1, true); @@ -3721,8 +3746,6 @@ unittest test("U0001f6" , `escape hex sequence has 6 hex digits instead of 8`, 0x0001f6, 7); test("U0001f60", `escape hex sequence has 7 hex digits instead of 8`, 0x0001f60, 8); - test("ud800" , `invalid UTF character \U0000d800`, '?', 5); - test("udfff" , `invalid UTF character \U0000dfff`, '?', 5); test("U00110000", `invalid UTF character \U00110000`, '?', 9); test("xg0" , `undefined escape hex sequence \xg`, 'g', 2); @@ -3734,6 +3757,9 @@ unittest test(""", `unterminated named entity "`, '?', 5); test("400", `escape octal sequence \400 is larger than \377`, 0x100, 3); + + test2("uD800", [`invalid UTF character \U0000d800`, `The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?`], '?', 5); + test2("uDFFF", [`invalid UTF character \U0000dfff`, `The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?`], '?', 5); } unittest From e8d0a7e0dbfbdaac3150e1cd1f0a67bba5125f37 Mon Sep 17 00:00:00 2001 From: "Richard (Rikki) Andrew Cattermole" Date: Thu, 7 Nov 2024 23:58:50 +1300 Subject: [PATCH 3/5] Fix bugzilla issue 24846 - atomicLoad does not work for class arguments with -preview=nosharedaccess --- dmd/expressionsem.d | 21 +++++++++++++++++++ dmd/frontend.h | 1 + dmd/id.d | 1 + ...es.d => atomic_loadstore_shared_classes.d} | 5 +++++ 4 files changed, 28 insertions(+) rename tests/dmd/compilable/{atomic_store_2_shared_classes.d => atomic_loadstore_shared_classes.d} (60%) diff --git a/dmd/expressionsem.d b/dmd/expressionsem.d index 5cf0cbb4cb..07b1347938 100644 --- a/dmd/expressionsem.d +++ b/dmd/expressionsem.d @@ -15136,6 +15136,27 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) { return false; } + else if (sc._module.ident == Id.atomic && sc._module.parent !is null) + { + // Allow core.internal.atomic, it is an compiler implementation for a given platform module. + // It is then exposed by other modules such as core.atomic and core.stdc.atomic. + // This is available as long as druntime is on the import path and the platform supports that operation. + + // https://issues.dlang.org/show_bug.cgi?id=24846 + + Package parent = sc._module.parent.isPackage(); + if (parent !is null) + { + // This can be easily converted over to apply to core.atomic and core.internal.atomic + if (parent.ident == Id.internal) + { + parent = parent.parent.isPackage(); + + if (parent !is null && parent.ident == Id.core && parent.parent is null) + return false; + } + } + } //printf("checkSharedAccess() `%s` returnRef: %d\n", e.toChars(), returnRef); diff --git a/dmd/frontend.h b/dmd/frontend.h index 845e4889e9..46b0efd8d1 100644 --- a/dmd/frontend.h +++ b/dmd/frontend.h @@ -8606,6 +8606,7 @@ struct Id final static Identifier* va_start; static Identifier* std; static Identifier* core; + static Identifier* internal; static Identifier* config; static Identifier* c_complex_float; static Identifier* c_complex_double; diff --git a/dmd/id.d b/dmd/id.d index f676361d95..f5d9340e86 100644 --- a/dmd/id.d +++ b/dmd/id.d @@ -389,6 +389,7 @@ immutable Msgtable[] msgtable = // Builtin functions { "std" }, { "core" }, + { "internal" }, { "config" }, { "c_complex_float" }, { "c_complex_double" }, diff --git a/tests/dmd/compilable/atomic_store_2_shared_classes.d b/tests/dmd/compilable/atomic_loadstore_shared_classes.d similarity index 60% rename from tests/dmd/compilable/atomic_store_2_shared_classes.d rename to tests/dmd/compilable/atomic_loadstore_shared_classes.d index 0d8cd74893..f719aa829f 100644 --- a/tests/dmd/compilable/atomic_store_2_shared_classes.d +++ b/tests/dmd/compilable/atomic_loadstore_shared_classes.d @@ -5,9 +5,14 @@ class Foo { } +shared Foo toLoad; + void oops() { auto f0 = new shared Foo; auto f1 = new shared Foo; atomicStore(f0, f1); + + // https://issues.dlang.org/show_bug.cgi?id=24846 + shared(Foo) f2 = atomicLoad(toLoad); } From 97b9d20d9df0a9e27b0088079ba9e334d6a8fcae Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 16 Nov 2024 19:35:56 +0100 Subject: [PATCH 4/5] compilable/stdcheaders.c: Work around unsupported NAN in new WinSDK headers GitHub Actions upgraded the WinSDK in the latest image, and its NAN is apparently not supported by ImportC anymore, breaking CI. --- tests/dmd/compilable/stdcheaders.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/dmd/compilable/stdcheaders.c b/tests/dmd/compilable/stdcheaders.c index c460a00384..2ea982e65b 100644 --- a/tests/dmd/compilable/stdcheaders.c +++ b/tests/dmd/compilable/stdcheaders.c @@ -21,8 +21,10 @@ #ifndef __APPLE__ // /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...` #include +#ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE float x = NAN; #endif +#endif #ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct #include From a6e32671ec11625d4d5afcea93efe8889b5318af Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 17 Nov 2024 14:52:36 +0100 Subject: [PATCH 5/5] Bump Phobos --- CHANGELOG.md | 2 +- runtime/phobos | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1018754203..e090682c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # LDC master #### Big news -- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768) +- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768, #4784) - LLVM for prebuilt packages bumped to v18.1.8 (incl. macOS arm64). (#4712) - Android: NDK for prebuilt package bumped from r26d to r27. (#4711) - ldc2.conf: %%ldcconfigpath%% placeholder added - specifies the directory where current configuration file is located. (#4717) diff --git a/runtime/phobos b/runtime/phobos index b7faca1c9b..e6d14f5151 160000 --- a/runtime/phobos +++ b/runtime/phobos @@ -1 +1 @@ -Subproject commit b7faca1c9bca5ed31ab82b0700ae45ca312727d7 +Subproject commit e6d14f51518719988db1b83ab7af541dc4824e95