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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Testcase:
#include <cstdint>

template<typename N, typename DataType>
struct Neighbourhood {
    using datatype = DataType;
};


template<typename B, typename N>
struct Building {
    using datatype = typename N::datatype;

    operator datatype() const{
        return (static_cast<B const *>(this)->contam_level);
    }
    void operator=(datatype const x) volatile {
        static_cast<B volatile*>(this)->contam_level = x;
    }
};

struct Cincin : public Neighbourhood<Cincin, uint32_t>
{
    struct Apartment : Building<Apartment, Cincin>{ 

        using Building<Apartment, Cincin>::operator=;
        Apartment(Apartment volatile & a) : contam_level(a.contam_level) {}
        Apartment(uint32_t const c = 0) : contam_level (c) {}

        union {
            struct
            {
                uint32_t laundry                       :3;
                uint32_t                               :5;
                uint32_t lobby                         :8;
                uint32_t                               :16;
            };
            uint32_t contam_level;
        };

        Apartment& Laundry(uint32_t val){
            this->laundry = val;
            return *this;
        }
    };
    Apartment volatile apartment;
};

Cincin cincin[2];


int main(){

  cincin[0].apartment = Cincin::Apartment().Laundry(0x7);
  //cincin[0].apartment = Cincin::Apartment(0x7);
  //cincin[0].apartment = 9;
}

Reply via email to