Skip to content

warning C4715: 'reflect::v1_2_5::offset_of<0,...>': not all control paths return a value #80

@jony999999

Description

@jony999999

warning in main branch

template<std::size_t N, class T> requires std::is_aggregate_v<std::remove_cvref_t<T>>
[[nodiscard]] constexpr auto offset_of() noexcept -> std::size_t {
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-var-template"
#endif
  const auto& unknown = detail::ext<detail::uninitialized<T>>;
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
  const void* address = __builtin_addressof(get<N>(unknown.value));
  for (std::size_t i = 0; i < sizeof(unknown.bytes); ++i) {
    if (address == &unknown.bytes[i]) {
      return i;
    }
  }
#if defined(__clang__)
  __builtin_unreachable();
#endif
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions