[Bug c++/39560] New: Erroneous wanings 'unused variable' in a templetated class method with union

yuri at tsoft dot com gcc-bugzilla@gcc.gnu.org
Thu Mar 26 04:43:00 GMT 2009


This testcase has warnings:
--- begin testcase ---
struct X { };

class Z {
public:
  X* cc(int c);
};

class F {
public:
  typedef X* (Z::*MethO)(int);
  typedef X* (F::*MethF)(int);
  template<MethO m>
  X* xwrapper(int i) {
    union {
      Z *z;
      F *f;
    };
    f = this;
    return ((z->*m)(i));
  }
};

F::MethF meth = &F::xwrapper<&Z::cc>;
--- end testcase ---
warnings:
c.C: In member function ‘X* F::xwrapper(int) [with X* (Z::* m)(int) = &Z::cc]’:
c.C:23:   instantiated from here
c.C:17: warning: unused variable ‘z’
c.C:17: warning: unused variable ‘f’


-- 
           Summary: Erroneous wanings 'unused variable' in a templetated
                    class method with union
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com


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



More information about the Gcc-bugs mailing list