public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id
@ 2021-06-09 17:06 felix.morgner at gmail dot com
  2021-06-09 17:12 ` [Bug c++/100997] " mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: felix.morgner at gmail dot com @ 2021-06-09 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100997
           Summary: [c++20] parse error when id-expression of constructor
                    is simple-template-id
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix.morgner at gmail dot com
  Target Milestone: ---

Created attachment 50972
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50972&action=edit
Example source file

In C++20 mode, GCC 11.1 rejects the following code:

  template<typename>
  struct A;

  template<>
  struct A<int> {
    A<int>() {}
  };

With the following error:

  <source>:6:12: error: expected unqualified-id before ')' token

I currently don't have access to my copy of the standard, but working from both
https://wg21.link/std and https://wg21.link/std20, I am under the expression
that this code should be valid since:

According to [class.ctor], the sole id-expression of the ptr-declarator of the
ctors function declarator may be the injected-class-name. [class.pre] tells us
that the class-name of the class being declared is injected into scope of the
class, where it is called the injected-class-name. Moreover, [class.pre]
defines a class-name to be either an indentifier or a simnple-template-id. I
would argue that in the case of the explicit specialization above, A<int> would
be a simple-template-id and thus a valid injected-class-name.

The error does not occur in C++17 mode or in GCC prior to version 11.

Tested in all cases with "-Wall -Wextra -Werror -pedantic-errors"

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

* [Bug c++/100997] [c++20] parse error when id-expression of constructor is simple-template-id
  2021-06-09 17:06 [Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id felix.morgner at gmail dot com
@ 2021-06-09 17:12 ` mpolacek at gcc dot gnu.org
  2021-06-09 17:17 ` mpolacek at gcc dot gnu.org
  2021-06-09 17:23 ` felix.morgner at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is C++20 DR 2237, disallow simple-template-id in cdtor: see 
[diff.cpp17.class]p2.

The diagnostic should be improved, we have bug 97202 for that.

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

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

* [Bug c++/100997] [c++20] parse error when id-expression of constructor is simple-template-id
  2021-06-09 17:06 [Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id felix.morgner at gmail dot com
  2021-06-09 17:12 ` [Bug c++/100997] " mpolacek at gcc dot gnu.org
@ 2021-06-09 17:17 ` mpolacek at gcc dot gnu.org
  2021-06-09 17:23 ` felix.morgner at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
To make it work just remove the "<int>" in A<int>() {}.

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

* [Bug c++/100997] [c++20] parse error when id-expression of constructor is simple-template-id
  2021-06-09 17:06 [Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id felix.morgner at gmail dot com
  2021-06-09 17:12 ` [Bug c++/100997] " mpolacek at gcc dot gnu.org
  2021-06-09 17:17 ` mpolacek at gcc dot gnu.org
@ 2021-06-09 17:23 ` felix.morgner at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: felix.morgner at gmail dot com @ 2021-06-09 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Felix Morgner <felix.morgner at gmail dot com> ---
Thank you for the quick response. I will file a bug report with Boost GIL.

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

end of thread, other threads:[~2021-06-09 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 17:06 [Bug c++/100997] New: [c++20] parse error when id-expression of constructor is simple-template-id felix.morgner at gmail dot com
2021-06-09 17:12 ` [Bug c++/100997] " mpolacek at gcc dot gnu.org
2021-06-09 17:17 ` mpolacek at gcc dot gnu.org
2021-06-09 17:23 ` felix.morgner at gmail dot com

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