public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct
@ 2020-04-12 20:19 msebor at gcc dot gnu.org
  2020-04-15 15:49 ` [Bug c++/94568] " msebor at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-04-12 20:19 UTC (permalink / raw)
  To: gcc-bugs

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;
      |                           ^~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/94568] template specialization of equivalent nontype template argument involving member pointer considered distinct
  2020-04-12 20:19 [Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct msebor at gcc dot gnu.org
@ 2020-04-15 15:49 ` msebor at gcc dot gnu.org
  2020-04-15 16:51 ` ensadc at mailnesia dot com
  2020-11-16 22:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-04-15 15:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Another test case, this one not involving pointers.  Somehow the form of the
initializer (= 0 vs { }) makes a difference.

$ cat t.C && gcc -O2 -c -Wall -std=c++2a t.C
template <C> struct D { };

constexpr const int i0 = 0;
constexpr const int i_{ };

static_assert (i0 == i_);

typedef D<C{ { 0, 1 } }>   DC01;
typedef D<C{ { i0, 1 } }>  DC01;
typedef D<C{ { i_, 1 } }>  DC01;
t.C:11:28: error: conflicting declaration ‘typedef struct D<C{int [2]{0, 1}}>
DC01’
   11 | typedef D<C{ { i_, 1 } }>  DC01;
      |                            ^~~~
t.C:10:28: note: previous declaration as ‘typedef struct D<C{int [2]{0, 1}}>
DC01’
   10 | typedef D<C{ { i0, 1 } }>  DC01;
      |                            ^~~~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/94568] template specialization of equivalent nontype template argument involving member pointer considered distinct
  2020-04-12 20:19 [Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct msebor at gcc dot gnu.org
  2020-04-15 15:49 ` [Bug c++/94568] " msebor at gcc dot gnu.org
@ 2020-04-15 16:51 ` ensadc at mailnesia dot com
  2020-11-16 22:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ensadc at mailnesia dot com @ 2020-04-15 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

ensadc at mailnesia dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ensadc at mailnesia dot com

--- Comment #2 from ensadc at mailnesia dot com ---
struct C { int a[2]; };
template <C> struct D { };
constexpr int i_{ };
typedef D<C{ { i_, 1 } }>  DC01;
void f(DC01) {}

The name of `f` is mangled as `_Z1f1DIXtl1CtlA2_iLKi0ELi1EEEEE`. The `LKi0E`
part seems to suggest that the element corresponding to `i_` has type `const
int`, where it should be a plain `int`.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/94568] template specialization of equivalent nontype template argument involving member pointer considered distinct
  2020-04-12 20:19 [Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct msebor at gcc dot gnu.org
  2020-04-15 15:49 ` [Bug c++/94568] " msebor at gcc dot gnu.org
  2020-04-15 16:51 ` ensadc at mailnesia dot com
@ 2020-11-16 22:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-16 22:17 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-11-16
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Adding the ABI keyword, since this seems to involve a mangling bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-16 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 20:19 [Bug c++/94568] New: template specialization of equivalent nontype template argument involving member pointer considered distinct msebor at gcc dot gnu.org
2020-04-15 15:49 ` [Bug c++/94568] " msebor at gcc dot gnu.org
2020-04-15 16:51 ` ensadc at mailnesia dot com
2020-11-16 22:17 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).