https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49171

Stas Sergeev <stsp at users dot sourceforge.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stsp at users dot 
sourceforge.net

--- Comment #17 from Stas Sergeev <stsp at users dot sourceforge.net> ---
The following code now breaks:
---
#include <cstddef>
#include <iostream>

template <typename T, char (T::*M)[0]>
struct offset_of {
    constexpr operator size_t() const {
        return (std::uintptr_t)&(static_cast<T*>(nullptr)->*M);
    }
};
template <typename T, char (T::*M)[0]>
struct B {
    char aa[10];
    static const int off = offset_of<T, M>();
};

struct A {
    char a;
    char _mark[0];
    B<A, &A::_mark> b;
};

int main()
{
    A a;
    std::cout << "size " << sizeof(A) << " off " << a.b.off << std::endl;
    return 0;
}
---

There is no other way of making offsetof(), rather
than by a reinterpret cast in constexpr (unless you
try very hard - I was still able to work around these
new gcc checks, but its tricky).

Would you consider adding this into -fpremissive?
Suddenly removing an extensions that people got used to,
is not the best treatment of users, AFAICT. Isn't -fpermissive
a right place for the extensions that people got used to?

Reply via email to