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

            Bug ID: 126561
           Summary: [c++26] typename-splice pseudo-destructor-name
                    rejected for scalar types (accepted for class types)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 121539739 at qq dot com
  Target Milestone: ---

Per [expr.prim.id.unqual], an unqualified-id can be `~ type-name` or
`~ computed-type-specifier`, and [dcl.type.simple] lists three
computed-type-specifiers: decltype-specifier, pack-index-specifier,
and splice-type-specifier. For a scalar type this forms a
pseudo-destructor name.

GCC accepts the typename-splice form when the object is of CLASS
type, but rejects it for scalar types, where only a plain type-name
works:

```cpp
// class type: accepted
struct S {};
void c1(S s) { s.~typename [:^^S:](); } // OK

// scalar type: rejected
void s1(int x) { x.~typename [:^^int:](); }
// error: expected identifier before 'typename'

// plain type-name pseudo-destructor works
using I = int;
void s0(int x) { x.~I(); }              // OK
```

Command line: g++ -std=c++26 -freflection

Expected: s1 should be accepted.

Reply via email to