Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

dli_fname is of type const char *.

dli_fname is of type const char *.
@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2025

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

Changes

dli_fname is of type const char *.


Full diff: https://github.com/llvm/llvm-project/pull/157312.diff

1 Files Affected:

  • (modified) llvm/lib/Support/Unix/Signals.inc (+1-2)
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 6cd38aabc734e..573ad82f2dea4 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -883,8 +883,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
     } else {
       const char *name = strrchr(dlinfo.dli_fname, '/');
       if (!name)
-        OS << format(" %-*s", width,
-                     static_cast<const char *>(dlinfo.dli_fname));
+        OS << format(" %-*s", width, dlinfo.dli_fname);
       else
         OS << format(" %-*s", width, name + 1);
     }

@kazutakahirata kazutakahirata merged commit 37a1fc5 into llvm:main Sep 7, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250906_cast_Signals branch September 7, 2025 00:14
@kikairoya
Copy link
Contributor

This breaks Cygwin build. see: #138117
IMO, format should accept const char (&)[].

tgymnich pushed a commit that referenced this pull request Oct 13, 2025
Cygwin builds are currently broken after #157312, which effectively
reverted #138117. The root cause is that Cygwin defines
`DL_info::dli_fname` as `char[N]`, which is not a valid parameter type
for `llvm::format`.

This patch allows `llvm::format` to accept `char[N]` by decaying it to
`const char *`. As a result, string literals are also accepted without
an explicit cast.

Other array types remain rejected:
- Wide/unicode character arrays (e.g., `wchar_t[N]`) are not supported,
as LLVM does not use them and they are less compatible with platform's
`printf` implementations.
- Non-character arrays (e.g., `int[N]`) are also rejected, since passing
such arrays to `printf` is meaningless.
DharuniRAcharya pushed a commit to DharuniRAcharya/llvm-project that referenced this pull request Oct 13, 2025
…9541)

Cygwin builds are currently broken after llvm#157312, which effectively
reverted llvm#138117. The root cause is that Cygwin defines
`DL_info::dli_fname` as `char[N]`, which is not a valid parameter type
for `llvm::format`.

This patch allows `llvm::format` to accept `char[N]` by decaying it to
`const char *`. As a result, string literals are also accepted without
an explicit cast.

Other array types remain rejected:
- Wide/unicode character arrays (e.g., `wchar_t[N]`) are not supported,
as LLVM does not use them and they are less compatible with platform's
`printf` implementations.
- Non-character arrays (e.g., `int[N]`) are also rejected, since passing
such arrays to `printf` is meaningless.
akadutta pushed a commit to akadutta/llvm-project that referenced this pull request Oct 14, 2025
…9541)

Cygwin builds are currently broken after llvm#157312, which effectively
reverted llvm#138117. The root cause is that Cygwin defines
`DL_info::dli_fname` as `char[N]`, which is not a valid parameter type
for `llvm::format`.

This patch allows `llvm::format` to accept `char[N]` by decaying it to
`const char *`. As a result, string literals are also accepted without
an explicit cast.

Other array types remain rejected:
- Wide/unicode character arrays (e.g., `wchar_t[N]`) are not supported,
as LLVM does not use them and they are less compatible with platform's
`printf` implementations.
- Non-character arrays (e.g., `int[N]`) are also rejected, since passing
such arrays to `printf` is meaningless.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants