Skip to content

Add BYN_WARN_UNUSED macro and apply to Name and IString - #8973

Open
sbc100 wants to merge 1 commit into
mainfrom
byn_warn_unused
Open

Add BYN_WARN_UNUSED macro and apply to Name and IString#8973
sbc100 wants to merge 1 commit into
mainfrom
byn_warn_unused

Conversation

@sbc100

@sbc100 sbc100 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Define BYN_WARN_UNUSED using [[gnu::warn_unused]] for GCC/Clang and fallback for other compilers. Annotating IString and Name with this attribute allows compilers to report unused variable diagnostics for default-constructed instances regardless of non-trivial constructors.

Followup to #8972.

Once this lands we can extend this to other types to get better coverage.

Define `BYN_WARN_UNUSED` using `[[gnu::warn_unused]]` for GCC/Clang
and fallback for other compilers. Annotating `IString` and `Name` with
this attribute allows compilers to report unused variable diagnostics
for default-constructed instances regardless of non-trivial constructors.

Followup to #8972.

Once this lands we can extend this to other types to get better
coverage.
@sbc100
sbc100 requested a review from a team as a code owner August 5, 2026 18:32
@sbc100
sbc100 requested review from aheejin and kripken and removed request for a team August 5, 2026 18:32
Comment thread src/support/istring.h
namespace wasm {

struct IString {
struct BYN_WARN_UNUSED IString {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels odd to me, to scatter these throughout the codebase. Is there no global flag we can set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean its kind of like llvm/llvm-project#203084.

If there was a flag I guess it would be something like "-falways-assume-ctors-have-no-side-effects" but I'm pretty sure that is never always true so you wouldn't want it to be global.

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.

2 participants