Skip to content

Fix clang build failure due to --verbosity option handling #2414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

jmarshall
Copy link
Member

Clang considers declaring a variable after a case label to be an error. Introduce a function encapsulating --verbosity parsing to avoid needing a local variable within this option parsing case.

Similarly in vcfmerge.c, avoid declaring a variable after a goto label.

(Perhaps this is valid in C11 and GCC is defaulting to that language level…)

@jmarshall jmarshall changed the title Fix clang build failure Fix clang build failure due to --verbosity option handling May 28, 2025
@jkbonfield
Copy link
Contributor

Looks good to me. Note I tried gcc -std=c99 -D_XOPEN_SOURCE=600 on mpileup.c and it compiles still with gcc11, but not with gcc10. So this appears to be something they relaxed. I also see my icc (not Intel's clang derivative, but the original icc) also warns on this.

(I also note our CI tests failed too.)

@jmarshall
Copy link
Member Author

jmarshall commented May 28, 2025

Apparently the C language's long-standing restrictions around jumping around side-stepping declarations have been relaxed in C23 and GCC 11 supports that as an extension for older language versions too.

I'm a bit surprised it's active with -std=c99 and doesn't require -std=gnu99, but happily you get a warning with ‑Wfree-labels or ‑pedantic.

Prior to C23, declaring a variable after a case label is an error.
Introduce a function encapsulating --verbosity parsing to avoid needing
a local variable within this option parsing case.

Similarly in vcfmerge.c, avoid declaring a variable after a goto label.
@jmarshall jmarshall force-pushed the no-decl-after-label branch from 8036764 to a4d4e59 Compare May 28, 2025 22:24
@pd3 pd3 merged commit e77ffb7 into samtools:develop May 29, 2025
8 checks passed
@pd3
Copy link
Member

pd3 commented May 29, 2025

Thank you

@jmarshall jmarshall deleted the no-decl-after-label branch May 29, 2025 10:00
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.

3 participants