[PATCH] stacktrace: label followed by a declaration is a C23 extension
Aaron Merey
amerey@redhat.com
Tue Jul 21 13:04:30 GMT 2026
Hi Mark,
On Mon, Jul 20, 2026 at 11:25 AM Mark Wielaard <mark@klomp.org> wrote:
>
> clang 22 complains about a label followed by a declaration in
> src/stacktrace.c because it doesn't default to C23.
>
> src/stacktrace.c:913:3: error: label followed by a declaration is a
> C23 extension [-Werror,-Wc23-extensions]
> 913 | bool is_abi32 = (regs->abi == PERF_SAMPLE_REGS_ABI_32);
> | ^
>
> This isn't a problem with gcc because it is a GNU extension.
>
> * src/stacktrace.c (sysprof_find_dwfl): But declarations after
> reuse label into block.
LGTM.
Aaron
>
> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
> src/stacktrace.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/src/stacktrace.c b/src/stacktrace.c
> index 83fb3d96455e..a7949ae14c83 100644
> --- a/src/stacktrace.c
> +++ b/src/stacktrace.c
> @@ -910,15 +910,18 @@ sysprof_find_dwfl (struct sysprof_unwind_info *sui,
> }
>
> reuse:
> - bool is_abi32 = (regs->abi == PERF_SAMPLE_REGS_ABI_32);
> - sui->last_sp = regs->regs[sp_reg_index(default_ebl, is_abi32)];
> - sui->last_base = sui->last_sp;
> -
> - if (show_frames) {
> - fprintf(stderr, "sysprof_find_dwfl pid %lld%s: size=%ld%s pc=%lx sp=%lx+(%lx)\n",
> - (long long) pid, cached ? " (cached)" : "",
> - ev->size, is_abi32 ? " (32-bit)" : "",
> - regs->regs[8], sui->last_base, (long)0);
> + {
> + bool is_abi32 = (regs->abi == PERF_SAMPLE_REGS_ABI_32);
> + sui->last_sp = regs->regs[sp_reg_index(default_ebl, is_abi32)];
> + sui->last_base = sui->last_sp;
> +
> + if (show_frames) {
> + fprintf(stderr,
> + "sysprof_find_dwfl pid %lld%s: size=%ld%s pc=%lx sp=%lx+(%lx)\n",
> + (long long) pid, cached ? " (cached)" : "",
> + ev->size, is_abi32 ? " (32-bit)" : "",
> + regs->regs[8], sui->last_base, (long)0);
> + }
> }
>
> if (!cached)
> --
> 2.54.0
>
More information about the Elfutils-devel
mailing list