Skip to content

Conversation

ockeydockey
Copy link
Contributor

@ockeydockey ockeydockey commented Sep 2, 2025

Some compilers will fail to build when a noexexcept statement is included in code built with exceptions turned off (IAR, for example). This fix replaces the remaining noexcept calls that weren't already using the ETL_NOEXCEPT macro to address this issue.

Summary by CodeRabbit

  • Refactor
    • Standardized exception specifications across the public API to improve portability and consistency. Updated byte operations, initializer_list methods, chrono comparisons and date literals, variant utilities (monostate operators, holds_alternative, get_if, swap, index), and string_view literal operators (narrow, wide, UTF-8/16/32) to use a unified macro.
    • No behavioral changes; signatures remain the same aside from the exception spec, ensuring source compatibility while aligning builds across different compilers and language levels.

@coderabbitai
Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Replaces direct noexcept specifiers with the ETL_NOEXCEPT macro across multiple headers. Affects byte operations, initializer_list, chrono comparisons and literals, variant utilities and helpers, and string_view literal operators. No parameter, return type, or body changes; non-C++11 paths remain unchanged where noted.

Changes

Cohort / File(s) Summary of Changes
Byte API exception-spec macro swap
include/etl/byte.h
All public to_integer and bitwise/shift operator declarations switch from noexcept to ETL_NOEXCEPT.
Initializer list exception-spec macro swap
include/etl/initializer_list.h
Constructors, begin/end/size, and free begin/end wrappers replace noexcept with ETL_NOEXCEPT across MSVC and GCC/Clang branches.
Chrono comparisons and literals exception-spec macro swap
include/etl/private/chrono/*
In day.h, month.h, month_day.h, time_point.h, year.h: spaceship operators and chrono literal UDLs change noexcept to ETL_NOEXCEPT; duplicate occurrences in time_point updated.
Variant API exception-spec macro swap
include/etl/private/variant_variadic.h
noexcept → ETL_NOEXCEPT across monostate operators (incl. <=>), variant members (valueless_by_exception, index, is_type, swap), holds_alternative, get_if overloads, and internal visit helper fptrs. No logic changes.
String_view literal operators exception-spec macro swap
include/etl/string.h, include/etl/u8string.h, include/etl/u16string.h, include/etl/u32string.h, include/etl/wstring.h
UDL operator ""_sv in each header changes noexcept to ETL_NOEXCEPT; signatures otherwise unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
include/etl/private/chrono/year.h (1)

127-142: Bug: years += / -= use unsigned char, causing wrap at 255.

This can corrupt year arithmetic (e.g., adding 300 years wraps). Not introduced by this PR but high-impact.

-        value += static_cast<unsigned char>(ys.count());
+        value = static_cast<rep>(value + static_cast<rep>(ys.count()));
...
-        value -= static_cast<unsigned char>(ys.count());
+        value = static_cast<rep>(value - static_cast<rep>(ys.count()));
🧹 Nitpick comments (5)
include/etl/private/chrono/month.h (1)

158-164: Nit: fix range in doc comment (12 months, not 31).

Change “valid 1 to 31 range” to “valid 1 to 12 range.”

-      /// Returns <b>true</b> if the month is within the valid 1 to 31 range
+      /// Returns <b>true</b> if the month is within the valid 1 to 12 range
include/etl/private/chrono/day.h (1)

85-91: Optional: add ETL_NOEXCEPT to templated assignment for consistency.

Other mutators are ETL_NOEXCEPT; if duration_cast is noexcept in your config, align this too.

-      ETL_CONSTEXPR14 etl::chrono::day& operator =(const etl::chrono::duration<TValue2, TPeriod2>& rhs)
+      ETL_CONSTEXPR14 etl::chrono::day& operator =(const etl::chrono::duration<TValue2, TPeriod2>& rhs) ETL_NOEXCEPT
include/etl/private/chrono/year.h (1)

229-256: Potential ordering bug for negative years: comparisons cast to unsigned.

Casting year to unsigned before compare mis-orders negatives. Consider comparing as signed (rep) instead.

-      return (static_cast<unsigned>(y1) < static_cast<unsigned>(y2));
+      return (static_cast<int>(y1) < static_cast<int>(y2));

(Apply similarly to ==, <=, >, >=.)

include/etl/byte.h (1)

79-79: Remove stray double semicolon

Minor formatting nit: extra ';' after the assignment.

-    return b = b << shift;;
+    return b = b << shift;
include/etl/private/variant_variadic.h (1)

1417-1420: Consider marking free swap as ETL_NOEXCEPT to mirror member swap

The member swap() is ETL_NOEXCEPT; the free swap can mirror it for consistency and noexcept propagation.

-  void swap(etl::variant<TTypes...>& lhs, etl::variant<TTypes...>& rhs)
+  void swap(etl::variant<TTypes...>& lhs, etl::variant<TTypes...>& rhs) ETL_NOEXCEPT
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c93440d and 64a2324.

📒 Files selected for processing (13)
  • include/etl/byte.h (5 hunks)
  • include/etl/initializer_list.h (7 hunks)
  • include/etl/private/chrono/day.h (2 hunks)
  • include/etl/private/chrono/month.h (1 hunks)
  • include/etl/private/chrono/month_day.h (2 hunks)
  • include/etl/private/chrono/time_point.h (1 hunks)
  • include/etl/private/chrono/year.h (2 hunks)
  • include/etl/private/variant_variadic.h (13 hunks)
  • include/etl/string.h (1 hunks)
  • include/etl/u16string.h (1 hunks)
  • include/etl/u32string.h (1 hunks)
  • include/etl/u8string.h (1 hunks)
  • include/etl/wstring.h (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: filipe-cuim
PR: ETLCPP/etl#1174
File: include/etl/type_traits.h:1974-1985
Timestamp: 2025-09-01T14:17:35.337Z
Learning: The current implementation in this PR correctly uses only individual trait flags (like ETL_USING_BUILTIN_IS_ASSIGNABLE) in preprocessor guards, not the global ETL_USE_TYPE_TRAITS_BUILTINS flag, because the global flag automatically defines all individual flags when enabled, making dual checks redundant.
🧬 Code graph analysis (5)
include/etl/private/chrono/month.h (2)
include/etl/private/chrono/day.h (4)
  • etl (35-203)
  • etl (323-332)
  • etl (337-353)
  • chrono (37-194)
include/etl/private/chrono/operators.h (1)
  • chrono (37-110)
include/etl/private/chrono/month_day.h (2)
include/etl/private/chrono/day.h (2)
  • etl (35-203)
  • chrono (37-194)
include/etl/private/chrono/month.h (22)
  • etl (35-155)
  • etl (358-358)
  • etl (359-359)
  • etl (360-360)
  • etl (361-361)
  • etl (362-362)
  • etl (363-363)
  • etl (364-364)
  • etl (365-365)
  • etl (367-390)
  • etl (368-370)
  • etl (377-386)
  • chrono (37-145)
  • chrono (344-344)
  • chrono (345-345)
  • chrono (346-346)
  • chrono (347-347)
  • chrono (348-348)
  • chrono (349-349)
  • chrono (350-350)
  • chrono (351-351)
  • chrono (352-352)
include/etl/private/chrono/day.h (2)
include/etl/private/chrono/month.h (23)
  • etl (35-155)
  • etl (358-358)
  • etl (359-359)
  • etl (360-360)
  • etl (361-361)
  • etl (362-362)
  • etl (363-363)
  • etl (364-364)
  • etl (365-365)
  • etl (367-390)
  • etl (368-370)
  • etl (377-386)
  • chrono (37-145)
  • chrono (344-344)
  • chrono (345-345)
  • chrono (346-346)
  • chrono (347-347)
  • chrono (348-348)
  • chrono (349-349)
  • chrono (350-350)
  • chrono (351-351)
  • chrono (352-352)
  • operator (379-385)
include/etl/private/chrono/duration.h (3)
  • etl (42-312)
  • etl (712-863)
  • chrono (44-246)
include/etl/private/chrono/year.h (3)
include/etl/private/chrono/day.h (5)
  • etl (35-203)
  • etl (323-332)
  • etl (337-353)
  • chrono (37-194)
  • operator (325-331)
include/etl/private/chrono/month.h (23)
  • etl (35-155)
  • etl (358-358)
  • etl (359-359)
  • etl (360-360)
  • etl (361-361)
  • etl (362-362)
  • etl (363-363)
  • etl (364-364)
  • etl (365-365)
  • etl (367-390)
  • etl (368-370)
  • etl (377-386)
  • chrono (37-145)
  • chrono (344-344)
  • chrono (345-345)
  • chrono (346-346)
  • chrono (347-347)
  • chrono (348-348)
  • chrono (349-349)
  • chrono (350-350)
  • chrono (351-351)
  • chrono (352-352)
  • operator (379-385)
include/etl/private/chrono/year_month.h (2)
  • chrono (37-121)
  • operator (274-285)
include/etl/private/variant_variadic.h (4)
include/etl/utility.h (4)
  • operator (447-450)
  • operator (482-485)
  • etl (51-92)
  • etl (56-59)
include/etl/optional.h (4)
  • etl (43-636)
  • T (397-405)
  • T (410-497)
  • T (995-1082)
include/etl/span.h (6)
  • etl (56-333)
  • `` (447-450)
  • `` (496-500)
  • `` (853-856)
  • `` (870-873)
  • `` (907-911)
include/etl/monostate.h (1)
  • etl (36-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: Clang C++20 OSX - No STL - Force C++03 (macos-13)
  • GitHub Check: Clang C++20 Linux - No STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: Clang C++20 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++20 Linux - No STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++20 Linux - STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - No STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++17 Linux - STL (ubuntu-22.04)
  • GitHub Check: Clang C++14 Linux - STL (ubuntu-22.04)
  • GitHub Check: Clang C++14 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++20 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - No STL (ubuntu-22.04)
  • GitHub Check: Clang C++17 Linux - STL (ubuntu-22.04)
  • GitHub Check: Clang C++17 Linux - No STL (ubuntu-22.04)
  • GitHub Check: Windows - No STL
  • GitHub Check: GCC C++14 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++11 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++11 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++14 Linux - No STL (ubuntu-22.04)
🔇 Additional comments (19)
include/etl/private/chrono/month.h (1)

264-267: LGTM: switched spaceship operator to ETL_NOEXCEPT.

Matches the PR intent and aligns with surrounding operators already using ETL_NOEXCEPT.

include/etl/private/chrono/month_day.h (2)

195-198: LGTM: month_day spaceship operator now uses ETL_NOEXCEPT.

Consistent with the rest of chrono operators.


324-327: LGTM: month_day_last spaceship operator now uses ETL_NOEXCEPT.

No behavioral changes; spec-only.

include/etl/private/chrono/time_point.h (2)

271-274: LGTM: time_point spaceship operator moved to ETL_NOEXCEPT.

Matches PR goal and surrounding API style.


1-286: No remaining raw noexcept; all occurrences use ETL_NOEXCEPT consistently.

include/etl/private/chrono/day.h (2)

262-265: LGTM: day spaceship operator switched to ETL_NOEXCEPT.

Consistent with other comparison operators here.


344-347: LGTM: chrono day literal operators now use ETL_NOEXCEPT.

Keeps literals consistent with macro-based spec.

include/etl/private/chrono/year.h (2)

262-265: LGTM: year spaceship operator switched to ETL_NOEXCEPT.

Matches the rest of the file.


360-363: LGTM: chrono year literal operators now use ETL_NOEXCEPT.

Consistent with other chrono literal updates.

include/etl/byte.h (1)

44-47: Consistent ETL_NOEXCEPT migration — LGTM

All affected byte APIs now use ETL_NOEXCEPT. Signatures and constexpr qualifiers are preserved; includes ensure the macro is available via platform.h.

Also applies to: 55-58, 66-69, 77-81, 88-91, 96-99, 104-107, 112-115, 120-123, 128-131, 136-139, 144-147

include/etl/initializer_list.h (1)

74-86: Initializer_list now uniformly uses ETL_NOEXCEPT — LGTM

Both MSVC and GCC/Clang branches are updated consistently (ctors, begin/end, size, and free functions). No behavioral changes.

Also applies to: 90-106, 120-131, 157-161, 165-181, 191-199, 205-215

include/etl/private/variant_variadic.h (2)

271-272: Variant API ETL_NOEXCEPT alignment — LGTM

Forward decls/defs of holds_alternative, monostate ops, variant::valueless_by_exception/index/is_type/swap, get_if overloads, and do_visit_helper::fptr are consistently migrated. Matches existing ETL usage elsewhere.

Also applies to: 308-316, 785-797, 815-823, 841-846, 1224-1229, 1235-1238, 1244-1247, 1354-1364, 1369-1379, 1383-1395, 1399-1411, 1564-1567


31-47: ETL_NOEXCEPT macro verified
ETL_NOEXCEPT is defined in include/etl/platform.h to expand to noexcept under C++11 (and empty pre-C++11) and no raw noexcept remains outside excluded files.

include/etl/string.h (2)

51-54: UDL now uses ETL_NOEXCEPT — looks good

Consistent with the PR intent and keeps the literal operator in lockstep with platform-specific noexcept handling.


51-54: Ensure ETL_NOEXCEPT is uniformly defined
ETL_NOEXCEPT is defined both as noexcept (platform.h:334) and as an empty macro (platform.h:353, plus test/vs2019/vs2022 hints), so confirm your build-configuration guards (e.g. exception-support flags) produce a single, consistent expansion across all TUs to avoid mismatched function types when taking the _sv operator’s address.

include/etl/u8string.h (1)

52-55: ETL_NOEXCEPT applied to u8string UDL — OK

Matches the macro standardization; no ABI or behavioral changes expected.

include/etl/u32string.h (1)

49-52: ETL_NOEXCEPT on u32string UDL — OK

Aligned with the rest of the literals; consistent include of platform.h ensures macro availability.

include/etl/wstring.h (1)

49-52: wstring UDL switched to ETL_NOEXCEPT — OK

Change is scoped to the exception spec only; body unchanged.

include/etl/u16string.h (1)

49-52: u16string UDL uses ETL_NOEXCEPT — OK

Consistent with the broader PR; no further issues spotted here.

@jwellbelove jwellbelove changed the base branch from master to development September 6, 2025 08:29
@jwellbelove jwellbelove merged commit b85b071 into ETLCPP:development Sep 6, 2025
1 check passed
@ockeydockey ockeydockey deleted the bugfix/ConvertAllNoexceptToMacro branch September 18, 2025 18:20
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