[Bug c++/34920] New: Members in nameless union

extronus at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 22 05:53:00 GMT 2008


Members in nameless union defined in template base class cannot be accessed by
template derived class. Methods in base class can access members.

Tried on 3.4.5 (mingw) and 4.1.2 (gentoo)

Simplified code :

template <typename TYPE>
class base
{
  public :
    typedef TYPE arrayType1[4];    
    typedef TYPE arrayType2[2][2]; 
    union {
      arrayType1 o; ///< One dimensional array
      arrayType2 t; ///< Two dimensional array

      struct
      {
        TYPE m11; TYPE m12; TYPE m13; TYPE m14;
      };
    };

    void base_funk()
    {
      o[0] = 0;
    }
};

template <typename TYPE>
class derived : public base<TYPE>
{
  public :
    void der_funk(TYPE v) {o[0] = v;}
};


-- 
           Summary: Members in nameless union
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: extronus at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34920



More information about the Gcc-bugs mailing list