public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107278] New: fails to correctly parse template default function declarations.
@ 2022-10-16 14:42 ky4ct at arrl dot net
  2022-10-16 15:16 ` [Bug c++/107278] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ky4ct at arrl dot net @ 2022-10-16 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107278
           Summary: fails to correctly parse template default function
                    declarations.
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ky4ct at arrl dot net
  Target Milestone: ---

Created attachment 53709
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53709&action=edit
minimal source code to reproduce the error.

This is specific to the -std=C++20 and -std=C++2b switches. The following
compiles fine by default and under C++ 11 and 14.

kd5eax@KY4CT UCRT64 ~
$ cat test.cpp
template<typename T>
class foo
{
        foo<T>(foo<T> const&) = delete;
        foo<T>(foo<T> const&&) = default;

};

int main()
{
        return 0;
};
kd5eax@KY4CT UCRT64 ~
$ g++ -std=c++20 test.cpp
test.cpp:4:22: error: expected ')' before 'const'
    4 |         foo<T>(foo<T> const&) = delete;
      |               ~      ^~~~~~
      |                      )
test.cpp:5:22: error: expected ')' before 'const'
    5 |         foo<T>(foo<T> const&&) = default;
      |               ~      ^~~~~~
      |                      )

kd5eax@KY4CT UCRT64 ~
$ g++ -v
Using built-in specs.
COLLECT_GCC=E:\msys64\ucrt64\bin\g++.exe
COLLECT_LTO_WRAPPER=E:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-12.2.0/configure --prefix=/ucrt64
--with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib
--enable-bootstrap --enable-checking=release --with-arch=x86-64
--with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts --enable-libstdcxx-time
--disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64
--with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64
--with-pkgversion='Rev1, Built by MSYS2 project'
--with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as
--with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++
--with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Rev1, Built by MSYS2 project)

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
@ 2022-10-16 15:16 ` pinskia at gcc dot gnu.org
  2022-10-16 15:24 ` ky4ct at arrl dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-16 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Iirc there was a defect report against the c++ standard here and you should
just foo instead of foo<T>

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
  2022-10-16 15:16 ` [Bug c++/107278] " pinskia at gcc dot gnu.org
@ 2022-10-16 15:24 ` ky4ct at arrl dot net
  2022-10-16 15:26 ` ky4ct at arrl dot net
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ky4ct at arrl dot net @ 2022-10-16 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan <ky4ct at arrl dot net> ---
(In reply to Andrew Pinski from comment #1)
> Iirc there was a defect report against the c++ standard here and you should
> just foo instead of foo<T>


kd5eax@KY4CT CLANG64 ~
$ cat test.cpp
template<typename T>
class foo
{
        foo<T>(foo<T> const&) = delete;
        foo<T>(foo<T> const&&) = default;

};

int main()
{
        return 0;
};
kd5eax@KY4CT CLANG64 ~
$ clang++ -std=c++20 test.cpp

kd5eax@KY4CT CLANG64 ~
$

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
  2022-10-16 15:16 ` [Bug c++/107278] " pinskia at gcc dot gnu.org
  2022-10-16 15:24 ` ky4ct at arrl dot net
@ 2022-10-16 15:26 ` ky4ct at arrl dot net
  2022-10-16 15:27 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ky4ct at arrl dot net @ 2022-10-16 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan <ky4ct at arrl dot net> ---
(In reply to Andrew Pinski from comment #1)
> Iirc there was a defect report against the c++ standard here and you should
> just foo instead of foo<T>


kd5eax@KY4CT CLANG64 ~
$ cat test.cpp
template<typename T>
class foo
{
        foo<T>(foo<T> const&) = delete;
        foo<T>(foo<T> const&&) = default;

};

int main()
{
        return 0;
};
kd5eax@KY4CT CLANG64 ~
$ clang++ -std=c++20 test.cpp

kd5eax@KY4CT CLANG64 ~
$

kd5eax@KY4CT UCRT64 ~
$ g++ -std=c++2b test.cpp
test.cpp:4:22: error: expected ')' before 'const'
    4 |         foo<T>(foo<T> const&) = delete;
      |               ~      ^~~~~~
      |                      )
test.cpp:5:22: error: expected ')' before 'const'
    5 |         foo<T>(foo<T> const&&) = default;
      |               ~      ^~~~~~
      |                      )

kd5eax@KY4CT UCRT64 ~
$ g++ test.cpp

kd5eax@KY4CT UCRT64 ~
$




(In reply to Andrew Pinski from comment #1)
> Iirc there was a defect report against the c++ standard here and you should
> just foo instead of foo<T>

If that is the case, can you please link the defect report against the
standard?

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
                   ` (2 preceding siblings ...)
  2022-10-16 15:26 ` ky4ct at arrl dot net
@ 2022-10-16 15:27 ` pinskia at gcc dot gnu.org
  2022-10-16 15:29 ` ky4ct at arrl dot net
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-16 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Clang might not implement the defect report after all ...

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
                   ` (3 preceding siblings ...)
  2022-10-16 15:27 ` pinskia at gcc dot gnu.org
@ 2022-10-16 15:29 ` ky4ct at arrl dot net
  2022-10-16 15:42 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ky4ct at arrl dot net @ 2022-10-16 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan <ky4ct at arrl dot net> ---
(In reply to Andrew Pinski from comment #4)
> Clang might not implement the defect report after all ...

This is why I asked for a link to it so I could understand this issue at its
core; at any rate, thanks for looking into this.

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
                   ` (4 preceding siblings ...)
  2022-10-16 15:29 ` ky4ct at arrl dot net
@ 2022-10-16 15:42 ` pinskia at gcc dot gnu.org
  2022-10-16 15:44 ` pinskia at gcc dot gnu.org
  2022-10-16 15:47 ` ky4ct at arrl dot net
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-16 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 103593.

CWG2237 is the defect report #.

*** This bug has been marked as a duplicate of bug 103593 ***

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
                   ` (5 preceding siblings ...)
  2022-10-16 15:42 ` pinskia at gcc dot gnu.org
@ 2022-10-16 15:44 ` pinskia at gcc dot gnu.org
  2022-10-16 15:47 ` ky4ct at arrl dot net
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-16 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> Dup of bug 103593.
> 
> CWG2237 is the defect report #.

From that defect report:
```
(Note that this resolution is a change for C++20, NOT a defect report against
C++17 and earlier versions.)
```
Which means it was not exactly a defect against previous versions of the
standard. It also means clang does not implement this part of the C++20
standard as it was published ...

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

* [Bug c++/107278] fails to correctly parse template default function declarations.
  2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
                   ` (6 preceding siblings ...)
  2022-10-16 15:44 ` pinskia at gcc dot gnu.org
@ 2022-10-16 15:47 ` ky4ct at arrl dot net
  7 siblings, 0 replies; 9+ messages in thread
From: ky4ct at arrl dot net @ 2022-10-16 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan <ky4ct at arrl dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #8 from Jonathan <ky4ct at arrl dot net> ---
Proposed resolution (November, 2017)

    Change 11.4.5 [class.ctor] paragraph 1 as follows:

        ...and the id-expression has one of the following forms:

            in a member-declaration that belongs to the member-specification of
a class or class template but is not a friend declaration (11.8.4
[class.friend]), the id-expression is the injected-class-name ( Clause 11
[class]) of the immediately-enclosing class; entity or

            in a member-declaration that belongs to the member-specification of
a class template but is not a friend declaration, the id-expression is a
class-name that names the current instantiation (13.8.3.2 [temp.dep.type]) of
the immediately-enclosing class template; or

            in a declaration at namespace scope or in a friend declaration, the
id-expression is a qualified-id that names a constructor (6.5.5.2
[class.qual]).

    Change 11.4.7 [class.dtor] paragraph 1 as follows:

        ...and the id-expression has one of the following forms:

            in a member-declaration that belongs to the member-specification of
a class or class template but is not a friend declaration (11.8.4
[class.friend]), the id-expression is ~class-name and the class-name is the
injected-class-name (Clause 11 [class]) of the immediately-enclosing class;
entity or

            in a member-declaration that belongs to the member-specification of
a class template but is not a friend declaration, the id-expression is
~class-name and the class-name names the current instantiation (13.8.3.2
[temp.dep.type]) of the immediately-enclosing class template; or

            in a declaration at namespace scope or in a friend declaration, the
id-expression is nested-name-specifier ~class-name and the class-name names the
same class as the nested-name-specifier.

    Add the following as a new paragraph in C.2 [diff.cpp17]:

        C.5.x Clause 15: Special member functions [diff.cpp17.special]

        Affected subclauses: 11.4.5 [class.ctor], 11.4.7 [class.dtor]
        Change: A simple-template-id is no longer valid as the declarator-id of
a constructor or destructor.
        Rationale: Remove potentially error-prone option for redundancy.
        Effect on original feature: Valid C++ 2017 code may fail to compile.

          template<class T>
          struct A {
            A<T>();  // error: simple-template-id not allowed for constructor
            A(int);  // OK, injected-class-name used
            ~A<T>(); // error: simple-template-id not allowed for destructor
          };

(Note that this resolution is a change for C++20, NOT a defect report against
C++17 and earlier versions.)

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

end of thread, other threads:[~2022-10-16 15:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 14:42 [Bug c++/107278] New: fails to correctly parse template default function declarations ky4ct at arrl dot net
2022-10-16 15:16 ` [Bug c++/107278] " pinskia at gcc dot gnu.org
2022-10-16 15:24 ` ky4ct at arrl dot net
2022-10-16 15:26 ` ky4ct at arrl dot net
2022-10-16 15:27 ` pinskia at gcc dot gnu.org
2022-10-16 15:29 ` ky4ct at arrl dot net
2022-10-16 15:42 ` pinskia at gcc dot gnu.org
2022-10-16 15:44 ` pinskia at gcc dot gnu.org
2022-10-16 15:47 ` ky4ct at arrl dot net

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).