what is wrong in this code? I have to use a volatile pointer to union, which gives error in operator overloading =.
===

<blink>
constvolatile.cpp:91:9: error: passing âvolatile GENERIC_COMMANDâ as âthisâ argument of âconst GENERIC_COMMAND& GENERIC_COMMAND::operator=(const T&) [with T = COMPLETION_WAIT, GENERIC_COMMAND = GENERIC_COMMAND]â discards qualifiers [-fpermissive]

</blink>
       
                #include <iostream>
                using namespace std;
                
                 typedef unsigned int uint32_t;
                 typedef unsigned long long  uint64_t;
                
                   union GENERIC_COMMAND
                    {
                        struct
                        {
                            uint64_t first_operand  :   60;
                            uint64_t opcode         :   4;
                            uint64_t second_operand :   64;
                        };
                
                        struct
                        {
                            uint32_t dword1;
                            uint32_t dword2;
                            uint32_t dword3;
                            uint32_t dword4;
                        };
                
                        struct
                        {
                            uint64_t qword1;
                            uint64_t qword2;
                        };
                
                        template <typename T>
                        const GENERIC_COMMAND& operator=(const T& rhs)
                        {
                            this->dword1 = rhs.dword1;
                            this->dword2 = rhs.dword2;
                            this->dword3 = rhs.dword3;
                            this->dword4 = rhs.dword4;
                            return *this;
                        }
                    };
                
                 
                 union COMPLETION_WAIT
                    {
                        struct
                        {
                            uint64_t s              :   1;
                            uint64_t i              :   1;
                            uint64_t f              :   1;
                            uint64_t store_address  :   49;
                            uint64_t reserved1      :   8;
                            uint64_t opcode         :   4;
                            uint64_t store_data     :   64;
                        };
                        struct
                        {
                            uint32_t dword1;
                            uint32_t dword2;
                            uint32_t dword3;
                            uint32_t dword4;
                        };
                    };
                
                 
                 void add_completion_wait_command(uint32_t s, uint32_t i, uint32_t f,
                                        uint64_t store_address, uint64_t store_data,
                                        bool auto_flush)
                    {
                        COMPLETION_WAIT command;
                        command.dword1 = 0;     
                        command.dword2 = 0;    
                        command.dword3 = 0;    
                        command.dword4 = 0;     
                
                        command.s = s;
                        command.i = i;
                        command.f = f;
                        command.store_address = store_address >> 3;
                        command.opcode = 0x1;
                        command.store_data = store_data;
                
                        GENERIC_COMMAND generic;
                        generic = command;
                       
                    }
                
                main()
                {
                        cout<< "in main"<< endl;
                        volatile GENERIC_COMMAND* A;//this has to be volatile only.
                        COMPLETION_WAIT cw;
                        A = new union GENERIC_COMMAND;
                        A[0] = cw;
                		//....
                }
