Skip to content

fix: make MUNI_NODISCARD the attribute under GCC 14's C23 too - #271

Merged
siracozmen01 merged 1 commit into
mainfrom
fix/nodiscard-gcc14
Nov 4, 2026
Merged

siracozmen01 merged 1 commit into
mainfrom
fix/nodiscard-gcc14

Conversation

@siracozmen01

Copy link
Copy Markdown
Contributor

Problem

MUNI_NODISCARD is meant to make every function that returns a status warn when its result is dropped. In C it expanded to [[nodiscard]] only when __STDC_VERSION__ >= 202311L. GCC 14 has the attribute in its C23 mode but reports __STDC_VERSION__ as 202000L there, under -std=c23 and -std=c2x alike. So under GCC the macro was empty:

  • A program built with GCC 14 could drop any status from the library without a warning.
  • The library's own GCC cells checked none of its internal calls either.

Clang 20 reports 202311L, which is why the clang cells never showed this. maul-locale found the same bug (Rawframe-Project/maul-locale#483) and fixed it in Rawframe-Project/maul-locale#484.

Change

In C, include/maul-unicode/base.h now takes the attribute in any dialect after C17 (__STDC_VERSION__ > 201710L) whose compiler defines __has_c_attribute and reports nodiscard. The __has_c_attribute test is nested under defined(__has_c_attribute), so a compiler without the operator never parses it. C17 and older dialects keep the empty expansion, and the C++ branch is unchanged. A comment explains GCC 14's 202000L. The block is maul-locale's at c346644, byte for byte except the prefix.

test/test_base.c asserts at compile time that the macro expands to something. Every suite builds as C23 with a compiler that has the attribute, so if the macro goes empty again, the build fails.

Verification

  • With main's base.h, test_base fails to build under GCC 14 with "static assertion failed: MUNI_NODISCARD is the attribute in C23". With this change it builds.
  • A file that drops the result of muniValidateUtf8 gets -Wunused-result from GCC 14 (-std=c23) with this change and nothing with main's header; Clang 20 warns with both.
  • The linux-gcc-14 cell builds with the attribute in effect, -Werror included: library, tools, samples, benchmarks and tests. No status is dropped anywhere, and all 13 tests pass.
  • The linux-harfbuzz cell (GCC 14, in ci-cpp:2026.10.7) builds the HarfBuzz adapter and its suites the same way, and all 16 tests pass.
  • tools/check.sh changed passes: rules, format, clang-tidy in Release and Debug, and the base and results suites under linux-clang-20-asan.

Closes #270

@siracozmen01 siracozmen01 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review at a9a85fd: ready. I read the change and did not run it. CI is pending.

The block in include/maul-unicode/base.h matches maul-locale's include/maul-locale/base.h at c346644 byte for byte apart from the prefix:

  • the comment's six lines;
  • the C++ branch;
  • the #elif with its continuation and the backslash at the same column;
  • the nested #if __has_c_attribute(nodiscard) and both #else / #endif pairs.

They are the same line for line, with MUNI_ in place of MLOC_. My review of maul-locale #484 holds for this copy. test/test_base.c takes the same TEXT/EXPANDED static_assert, with the prefix, after its existing includes, and its header comment now names the result attribute. fix without ! is right at 1.x: a program gets a warning where the attribute was always meant to apply. The body has no column-0 name( lines and no em dash.

@siracozmen01
siracozmen01 merged commit e206d49 into main Nov 4, 2026
24 checks passed
@siracozmen01
siracozmen01 deleted the fix/nodiscard-gcc14 branch November 4, 2026 23:37
@rawframe-release rawframe-release Bot mentioned this pull request Nov 4, 2026
siracozmen01 pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


## [1.1.1](v1.1.0...v1.1.1) (2026-11-04)

### Fixed

- `MUNI_NODISCARD` was empty under GCC 14 in C23, since GCC 14 reports
  its C23 as `__STDC_VERSION__` 202000L and the macro waited for
  202311L, so a program built with GCC 14 could drop any status the
  library returns without a warning. In C the macro now takes
  `[[nodiscard]]` in any dialect after C17 whose compiler has the
  attribute. A program that drops a status now gets
  `-Wunused-result` from GCC 14 too, which `-Werror` makes an error
  ([#271](#271)).

No results change: the Unicode data is still 18.0.0 and
`MUNI_RESULTS_VERSION` stays 2, so stored normalized keys, skeletons
and verdicts from 1.1.0 stay valid.
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.

MUNI_NODISCARD is empty under GCC 14 in C23

1 participant