[Bug c++/126599] [reflection] display_string_of(nullptr-pointer-to-data-member) is "-1"
"jakub at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 14:48:42 +0000
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126599
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For
struct S { int s, t; };
template <auto M>
void foo (int);
void
bar ()
{
foo <(int S::*)nullptr> ();
foo <&S::s> ();
foo <&S::t> ();
}
we diagnose
pr126599.C: In function =E2=80=98void bar()=E2=80=99:
pr126599.C:7:27: error: no matching function for call to =E2=80=98foo<-1>()=
=E2=80=99
7 | foo <(int S::*)nullptr> ();
| ~~~~~~~~~~~~~~~~~~~~~~~~^~
=E2=80=A2 there is 1 candidate
=E2=80=A2 candidate 1: =E2=80=98template<auto M> void foo(int)=E2=80=99
pr126599.C:3:6:
3 | void foo (int);
| ^~~
=E2=80=A2 candidate expects 1 argument, 0 provided
pr126599.C:8:15: error: no matching function for call to =E2=80=98foo<&S::s=
>()=E2=80=99
8 | foo <&S::s> ();
| ~~~~~~~~~~~~^~
=E2=80=A2 there is 1 candidate
=E2=80=A2 candidate 1: =E2=80=98template<auto M> void foo(int)=E2=80=99
pr126599.C:3:6:
3 | void foo (int);
| ^~~
=E2=80=A2 candidate expects 1 argument, 0 provided
pr126599.C:9:15: error: no matching function for call to =E2=80=98foo<&S::t=
>()=E2=80=99
9 | foo <&S::t> ();
| ~~~~~~~~~~~~^~
=E2=80=A2 there is 1 candidate
=E2=80=A2 candidate 1: =E2=80=98template<auto M> void foo(int)=E2=80=99
pr126599.C:3:6:
3 | void foo (int);
| ^~~
=E2=80=A2 candidate expects 1 argument, 0 provided
&S::s and &S::t is printed for PTRMEM_CST, while -1 is printed for OFFSET_T=
YPE
INTEGER_CST:
216 /* A NULL pointer-to-data-member is represented by -1, not by
217 zero. */
218 tree val =3D (TYPE_PTRDATAMEM_P (type)
219 ? build_int_cst_type (type, -1)
220 : build_int_cst (type, 0));=