Skip to content

Conversation

@a666
Copy link
Contributor

@a666 a666 commented Oct 27, 2025

Summary

Build "Fix clang 21 warnings"

Purpose of change

Recently arch linux updated clang from 20.1.8 to 21.1.4.

This made a new compilation warning appear.

error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]

Describe the solution

Added __attribute__((noreturn)) to lambdas with the warning.

Describe alternatives you've considered

I have minimal experience with c++ projects, I'm unsure if this is the correct solution (code quality wise? a better way to set these attributes?), if someone with more experience could provide guidance that would be helpful.
Perhaps it would be better to just disable the warning in the Makefile?
I don't have any preference for a solution, I'm open to amending the commit.

Testing

Game compiles with clang and g++ without warnings, visual studio compilation untested since I'll go feral the moment I'll use f***ing Windows for anything.

Additional context

https://releases.llvm.org/21.1.0/tools/clang/docs/ReleaseNotes.html

@github-actions github-actions bot added Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments json-styled JSON lint passed, label assigned by github actions labels Oct 27, 2025
@ehughsbaird
Copy link
Contributor

This is a bug in clang 21.1.4, fixed in clang 22 llvm/llvm-project#154493.

I think filing a report requesting a backport is preferable to trying to use a language feature that isn't quite here yet (see the failing Windows build).
If we do choose to work around it here, until C++23 provides the language support for this, the attributes will need to be specified as a macro so that only clang see them.

#ifdef __clang__
#define LAMBDA_NORETURN __attribute__( ( noreturn ) )
#else
#define LAMBDA_NORETURN
#end

@a666
Copy link
Contributor Author

a666 commented Oct 27, 2025

I wasn't sure were to put the #define to make it DRY so I made a new header.
If there's a better place I'll move it.

@ehughsbaird
Copy link
Contributor

Could you rename it to cata_compiler_support.h? You could also absorb cata_inline.h into it, but don't need to. Please also add a comment mentioning that it can be removed and replaced with [[noreturn]] with C++23 (for all compilers).

@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Oct 27, 2025
Due to
error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]

ref:
llvm/llvm-project#154493
@a666
Copy link
Contributor Author

a666 commented Oct 29, 2025

Copy link
Contributor

@ehughsbaird ehughsbaird left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

astyled astyled PR, label is assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Crafting / Construction / Recipes Includes: Uncrafting / Disassembling json-styled JSON lint passed, label assigned by github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants