[Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 12 20:19:15 GMT 2020


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

            Bug ID: 94568
           Summary: template specialization of equivalent nontype template
                    argument involving member pointer considered distinct
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

I believe the two definitions of XB below are the same and should be accepted. 
GCC for some reason not evident from the error message treats them as distinct.

$ cat t.C && gcc -O2 -S -Wall -std=c++2a t.C
struct A;
typedef int A::*MemPtr;

struct B { MemPtr p; };

static constexpr MemPtr mp { };

template <B> struct X { };

typedef X<B{{MemPtr{ }}}> XB;
typedef X<B{{mp}}>        XB;
t.C:11:27: error: conflicting declaration ‘typedef struct X<B{-1}> XB’
   11 | typedef X<B{{mp}}>        XB;
      |                           ^~
t.C:10:27: note: previous declaration as ‘typedef struct X<B{-1}> XB’
   10 | typedef X<B{{MemPtr{ }}}> XB;
      |                           ^~


More information about the Gcc-bugs mailing list