Issue 63443
Summary `offsetof()` doesn't support `::` in member names
Labels
Assignees
Reporter HolyBlackCat
    I'm not sure what the standard has to say about it, but GCC and MSVC accept it, and it can be a useful feature.

E.g. GCC and MSVC accept following code:
```cpp
#include <cstddef>
#include <iostream>

struct Empty {};

#define FOO [[no_unique_address]] Empty e;

struct A
{
    FOO int x;
};

struct B
{
    FOO int y;
};

struct C : A, B
{
    FOO int z;
};

template <typename D, typename B>
constexpr std::size_t base_offset = offsetof(D, B::e);

int main()
{
    std::cout << base_offset<C, A> << '\n'; // 0
    std::cout << base_offset<C, B> << '\n'; // 4
    std::cout << base_offset<C, C> << '\n'; // 8
}
```

While Clang trunk says:
```none
<source>:24:50: error: expected ')'
   24 | constexpr std::size_t base_offset = offsetof(D, B::e);
      | ^
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to