From 34cf3a95031408e747a0c904c0f98170d09244c6 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 19 Feb 2025 06:42:21 +0100 Subject: [PATCH] Fix #20894 (#20895) - pragma(msg) interprets printf format specifiers --- compiler/src/dmd/pragmasem.d | 2 +- compiler/test/compilable/bug11735.d | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dmd/pragmasem.d b/compiler/src/dmd/pragmasem.d index 3a455fb3d1..eb84d83705 100644 --- a/compiler/src/dmd/pragmasem.d +++ b/compiler/src/dmd/pragmasem.d @@ -568,7 +568,7 @@ private bool pragmaMsgSemantic(Loc loc, Scope* sc, Expressions* args) else { buf.writestring("\n"); - fprintf(stderr, buf.extractChars); + fprintf(stderr, "%s", buf.extractChars); } return true; } diff --git a/compiler/test/compilable/bug11735.d b/compiler/test/compilable/bug11735.d index b94cb6e77d..be61a50585 100644 --- a/compiler/test/compilable/bug11735.d +++ b/compiler/test/compilable/bug11735.d @@ -13,6 +13,7 @@ print dstring foo_str foo_wstr foo_dstr +X%nY --- */ @@ -33,4 +34,7 @@ void main() pragma(msg, a); pragma(msg, b); pragma(msg, c); + + // https://github.com/dlang/dmd/issues/20894 + pragma(msg, "X%nY"); }