Skip to content

COMP: Fix spFactor.c K&R prototypes for C23 compilers (GCC 15+/16)#6437

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:release-4.14from
gdevenyi:fix-spfactor-c23-prototypes
Jun 14, 2026
Merged

COMP: Fix spFactor.c K&R prototypes for C23 compilers (GCC 15+/16)#6437
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:release-4.14from
gdevenyi:fix-spfactor-c23-prototypes

Conversation

@gdevenyi

Copy link
Copy Markdown
Contributor

Problem

GCC 15+ (Fedora 42/43/44, GCC 16 locally) defaults to C23, where an empty () function prototype means (void) instead of K&R unspecified-args. VXL's bundled netlib v3p/netlib/sparse/spFactor.c has four block-scope re-declarations of FindBiggestInColExclude / FindLargestInCol with empty (), then calls them with arguments. C23 rejects this:

error: too many arguments to function 'FindBiggestInColExclude'; expected 0, have 3
error: conflicting types for 'FindBiggestInColExclude'; have 'RealNumber(void)'

This breaks the ITK build on every C23-default toolchain. Reported downstream in BIC-MNI/minc-toolkit-v2#197, which works around it by forcing -std=gnu17 on ITK's C flags — a build-flag workaround rather than a source fix.

Fix

The file already carries correct file-scope static prototypes (lines 81-82). Replace the four stale empty-paren block-scope re-declarations with the full signatures so () no longer collapses to (void) under C23. C-only; pure prototype tightening with no codegen change under pre-C23 compilers, and no global -std override required.

Validation

With GCC 16.1.1:

  • pre-edit: gcc -std=c23 -fsyntax-only reproduces the too many arguments / conflicting types errors above
  • post-edit: compiles cleanly with no -std override

Note: gcc-16 detection in vcl/vcl_compiler.h is already present (VCL_GCC_16, cascade extended through gcc-20 in 4f97f72), so no compiler-detection change is needed.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 12, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added type:Compiler Compiler support or related warnings area:ThirdParty Issues affecting the ThirdParty module labels Jun 12, 2026
@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a C23 build regression in VXL's bundled netlib spFactor.c by replacing four stale K&R empty-paren block-scope function re-declarations with explicit parameter-typed prototypes. The new signatures are identical to the existing file-scope static prototypes already present at lines 81-82, so no semantic or codegen change occurs under any compiler.

  • Three block-scope RealNumber FindBiggestInColExclude() re-declarations are updated to FindBiggestInColExclude( MatrixPtr, ElementPtr, int ), matching the file-scope static prototype.
  • One block-scope RealNumber FindLargestInCol() re-declaration is updated to FindLargestInCol( ElementPtr ), likewise matching its file-scope prototype.

Confidence Score: 5/5

Straightforward prototype-only fix with no logic or codegen change; the updated signatures exactly mirror the existing file-scope static declarations.

All four block-scope re-declarations are updated to signatures that already exist verbatim as file-scope static prototypes in the same file. There is no behavior change under pre-C23 compilers and the build error under C23 is correctly resolved.

No files require special attention.

Important Files Changed

Filename Overview
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/sparse/spFactor.c Four stale K&R empty-paren block-scope re-declarations replaced with full parameter-typed prototypes matching the existing file-scope static declarations at lines 81-82; no logic change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[C23 compiler GCC 15 or later] -->|empty parens means void| B[Block-scope re-declaration RealNumber FindBiggestInColExclude]
    B -->|conflicting types error| C[Build failure]
    D[File-scope static prototype with full parameter list] -->|already correct| E[Block-scope re-declaration updated to match]
    E -->|consistent types| F[Builds cleanly under C23]
Loading

Reviews (1): Last reviewed commit: "COMP: Give spFactor.c K&R prototypes ful..." | Re-trigger Greptile

@dzenanz

dzenanz commented Jun 12, 2026

Copy link
Copy Markdown
Member

@hjmjohnson Is there some chance you could fix CI in release-4.14 branch?

@hjmjohnson

Copy link
Copy Markdown
Member

@hjmjohnson Is there some chance you could fix CI in release-4.14 branch?

@dzenanz I can work with "claude" and monitor it's efforts :). Almost certainly a low human effort at this point!

@hjmjohnson

Copy link
Copy Markdown
Member

The red checks here are infrastructure, not this PR: the release-4.14 Azure pipelines request hosted agent images retired years ago. CI restoration is underway in #6440; once that merges, a re-run/rebase here should go green.

GCC 15+ (Fedora 42/43/44, GCC 16 locally) defaults to C23, where an empty
() function prototype means (void) instead of K&R unspecified-args. VXL's
bundled netlib v3p/netlib/sparse/spFactor.c carries four block-scope
re-declarations of FindBiggestInColExclude / FindLargestInCol with empty
(), then calls them with arguments, which C23 rejects:

  error: too many arguments to function 'FindBiggestInColExclude';
         expected 0, have 3
  error: conflicting types for 'FindBiggestInColExclude';
         have 'RealNumber(void)'

The file already has correct file-scope static prototypes (lines 81-82).
Replace the four stale empty-paren block-scope declarations with the full
signatures so () no longer collapses to (void) under C23. C-only; pure
prototype tightening with no codegen change under pre-C23 compilers.

Verified with gcc 16.1.1: pre-edit reproduces the errors above under
-std=c23, post-edit compiles cleanly with no -std override.

Change-Id: Ia375f3875b239ddf5c292e6772503c96f8b50866
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hjmjohnson hjmjohnson force-pushed the fix-spfactor-c23-prototypes branch from de7f0c4 to d1336ff Compare June 14, 2026 16:26
@hjmjohnson hjmjohnson merged commit cae3eb9 into InsightSoftwareConsortium:release-4.14 Jun 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ThirdParty Issues affecting the ThirdParty module type:Compiler Compiler support or related warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants