Dear all,

I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.

We use the compiler to generate code for a PowerPC processor.

Used invokation line for the GNU C++ compiler:

ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
      -fmerge-templates -mmultiple -mno-string -mstrict-align -O3
      -fno-exceptions -fno-rtti -fno-builtin-printf
      -I<some include paths>
      -D<some #define's>
      X.CPP -oX.O


// file X.CPP

void g (void*);

struct ABC
{
    template <typename T_, typename U_>
    ABC (void (T_::* ptrFunc)(), U_& refObj)
    {
        T_* pObj = &refObj;
        g (pObj);                   // <--- line 9
    }
};

struct DEF
{
    void f () const;
};

DEF def;
ABC abc(&DEF::f, def);


The compiler gives the following error message:

X.CPP: In constructor `ABC::ABC(void (T_::*)(), U_&) [with T_ = const DEF, 
       U_ = DEF]':
X.CPP:19:   instantiated from here
X.CPP:9: error: invalid conversion from `const void*' to `void*'


The compilation of the code above fails but for a wrong reason: it should fail
because the pointer to function f has type 'void (DEF::*)() const' and there
is no constructor available whose first parameter fits the mentioned type.

But the GNU compiler erronously deduces the type 'void (const DEF::*)()' for
the first constructor parameter as the error message shows.


Kind regards
W. Roehrl


-- 
           Summary: Type deduction of a pointer-to-member
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wolfgang dot roehrl at gi-de dot com
 GCC build triplet: sparc-sun-solaris2.5.1
  GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks


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

Reply via email to