Fix some strchr (discarded) qualifier issues with C23

Project / Subsystem

binutils / binutils

Date

2026-05-02

Proposer

Mark Wielaard <mark@klomp.org>

Source type

public_inbox

Consensus

Under Review

Sentiment

/10

Technical tradeoffs

  • Code changes needed to accommodate the new constness may introduce subtle bugs if not handled carefully.
  • Ignoring the warnings could lead to undefined behavior if the code attempts to modify a const string.
  • The fix might require casting away constness in some cases, which should be done with caution.

All attributes

project
binutils
subsystem
binutils
patch_id
discussion_id
20260502170132.3303884-1-mark@klomp.org
source_type
public_inbox
title
Fix some strchr (discarded) qualifier issues with C23
headline
Fix strchr qualifier issues with C23.
tldr
The patch series fixes build errors due to implicit const conversions when compiling binutils with GCC 16.1 in C23 mode.
proposer
Mark Wielaard <mark@klomp.org>
consensus
Under Review
outcome
proposed
sentiment_score
technical_tradeoffs
  • Code changes needed to accommodate the new constness may introduce subtle bugs if not handled carefully.
  • Ignoring the warnings could lead to undefined behavior if the code attempts to modify a const string.
  • The fix might require casting away constness in some cases, which should be done with caution.
series_id
series_role
standalone
series_parts
[]
tags
  • binutils
  • C23
  • const
  • strchr
  • gcc
bugzilla_url
date
2026-05-02T00:00:00.000Z

Fix some strchr (discarded) qualifier issues with C23

With GCC 16.1 defaulting to C23, the stricter constness of functions like strchr in glibc 2.43 trigger -Werror=discarded-qualifiers errors in binutils. This patch series updates calls to strchr and similar functions to handle the const char * return type when given a const char * argument. This resolves build failures and ensures compatibility with the updated C standard and glibc.