Thanks to visit codestin.com
Credit goes to cplusplus.github.io


This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4538. member_offset::total_bits should be noexcept

Section: 21.4.11 [meta.reflection.layout] Status: New Submitter: Hewill Kang Opened: 2026-03-10 Last modified: 2026-04-13

Priority: 3

View all other issues in [meta.reflection.layout].

View all issues with New status.

Discussion:

This member simply returns the result of integer calculations, which can be noexcept.

[2026-04-13; Reflector poll.]

Set priority to 3 after reflector poll.

"The calculation can overflow ptrdiff_t which would be undefined, so there's an implicit narrow contract."

Proposed resolution:

This wording is relative to N5032.

  1. Modify 21.4.11 [meta.reflection.layout] as indicated:

    struct member_offset {
      ptrdiff_t bytes;
      ptrdiff_t bits;
      constexpr ptrdiff_t total_bits() const noexcept;
      auto operator<=>(const member_offset&) const = default;
    };
    
    constexpr ptrdiff_t member_offset::total_bits() const noexcept;
    

    -1- Returns: bytes * CHAR_BIT + bits.