offset_based_getter produces wrong result with clang on non-X86 platform
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 176
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 1
Description
The attached mini reproducer fails if compiled with Clang-16 on non-X86 platform:
```
#include
#include
#include
struct user_type {
char c;
double d;
};
int main() {
using pfr_tuple = boost::pfr::detail::sequence_tuple::tuple;
using getter = boost::pfr::detail::offset_based_getter;
using boost::pfr::detail::size_t_;
using boost::pfr::detail::sequence_tuple::get;
user_type value{};
auto begin = reinterpret_cast(&value);
auto native_offset = reinterpret_cast(&value.d) - begin;
auto getter_offset = reinterpret_cast(&getter{}.get(value, size_t_<1>{})) - begin;
if (native_offset != getter_offset) {
printf("native_offset != getter_offset ('%li' != '%li')\n", native_offset, getter_offset);
printf("FAIL\n");
} else {
printf("PASS\n");
}
}
```
Test output is:
```
native_offset != getter_offset ('8' != '4')
FAIL
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached reproducer and inspect boost/pfr/detail/offset_based_getter.hpp and boost/pfr/detail/sequence_tuple.hpp. Compile it with Clang 16 on the affected non-X86 platform, compare the native and getter offsets, and consider the issue done when both offsets match and the reproducer prints PASS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100