Skip to content

Commit

Permalink
Replace GC-allocated printf cstring with length/ptr pair
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Korpel authored and Geod24 committed Nov 19, 2024
1 parent 2684537 commit a130fa2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -6151,8 +6151,7 @@ public:
}
error(e.loc, "array cast from `%s` to `%s` is not supported at compile time", e1.type.toChars(), e.to.toChars());
if (se && se.hexString && se.postfix != StringExp.NoPostfix)
errorSupplemental(e.loc, "perhaps remove postfix `%s` from hex string",
(cast(char) se.postfix ~ "\0").ptr);
errorSupplemental(e.loc, "perhaps remove postfix `%.*s` from hex string", 1, &se.postfix);

result = CTFEExp.cantexp;
return;
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -9337,7 +9337,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
"cast from `%s` to `%s` not allowed in safe code", exp.e1.type, exp.to))
{
if (msg.length)
errorSupplemental(exp.loc, "%s", (msg ~ '\0').ptr);
errorSupplemental(exp.loc, "%.*s", msg.fTuple.expand);
return setError();
}
}
Expand All @@ -9347,7 +9347,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
"cast from `%s` to `%s` not allowed in safe code", exp.e1.type, exp.to);
// if message was printed
if (sc.func && sc.func.isSafeBypassingInference() && !sc.isDeprecated())
deprecationSupplemental(exp.loc, "%s", (msg ~ '\0').ptr);
deprecationSupplemental(exp.loc, "%.*s", msg.fTuple.expand);
if (err)
return setError();
}
Expand Down

0 comments on commit a130fa2

Please sign in to comment.