Skip to content

common/wireaddr: fix GCC 15 const-qualifier errors#9075

Open
vincenzopalazzo wants to merge 1 commit intoElementsProject:masterfrom
vincenzopalazzo:claude/upbeat-vaughan-6a00b7
Open

common/wireaddr: fix GCC 15 const-qualifier errors#9075
vincenzopalazzo wants to merge 1 commit intoElementsProject:masterfrom
vincenzopalazzo:claude/upbeat-vaughan-6a00b7

Conversation

@vincenzopalazzo
Copy link
Copy Markdown
Collaborator

Summary

  • GCC 15 propagates the const qualifier through strchr/strrchr, so the result of strchr(const char *, c) is const char *. The two locals in separate_address_and_port were declared as char *, tripping -Werror=discarded-qualifiers on Arch Linux / GCC 15.2.1.
  • Change portcolon and end to const char *. Both are only read (pointer arithmetic and comparisons), so no behavior change.

Fixes #9074.

Test plan

  • make common/wireaddr.o — compiles cleanly
  • make common/test/run-ip_port_parsing && common/test/run-ip_port_parsing — passes

@vincenzopalazzo vincenzopalazzo force-pushed the claude/upbeat-vaughan-6a00b7 branch from 7af7c64 to d4dc427 Compare April 21, 2026 12:47
GCC 15 propagates the const qualifier through strchr/strrchr, so the
result of strchr(const char *, c) is const char *. Declaring the locals
as char * triggers -Werror=discarded-qualifiers:

    common/wireaddr.c: In function 'separate_address_and_port':
    common/wireaddr.c:297:29: error: initialization discards 'const'
      qualifier from pointer target type [-Werror=discarded-qualifiers]
    common/wireaddr.c:304:27: error: assignment discards 'const'
      qualifier from pointer target type [-Werror=discarded-qualifiers]

Make portcolon and end const char * to match; both are only read.

Fixes: ElementsProject#9074
Changelog-Fixed: build: fix build errors with GCC 15 (Arch Linux).
@vincenzopalazzo vincenzopalazzo force-pushed the claude/upbeat-vaughan-6a00b7 branch from d4dc427 to d1c142c Compare April 21, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build error v26.04

1 participant