public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
@ 2020-10-01  7:08 ` lisyarus at gmail dot com
  2020-10-01 13:35 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: lisyarus at gmail dot com @ 2020-10-01  7:08 UTC (permalink / raw)
  To: gcc-bugs

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

Nikita Lisitsa <lisyarus at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lisyarus at gmail dot com

--- Comment #5 from Nikita Lisitsa <lisyarus at gmail dot com> ---
Any updates on this? Can confirm this on all gcc versions from 7.1 to 10.2 (see
https://godbolt.org/z/4qnfea). Interestingly, for a variadic-template
constructor only the first argument triggers the error, i.e.

template <typename T>
struct A
{
    A(T) {}
};

template <typename T>
A(T) -> A<T>;

template <typename T>
struct B
{

    template <typename ... Args>
    B(Args const & ...){}

};

void test()
{
    B<int> b1(A{0}, A{0}, A{0}); // error
    B<int> b2(A<int>{0}, A{0}, A{0}); // ok
}

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
  2020-10-01  7:08 ` [Bug c++/89062] class template argument deduction failure with parentheses lisyarus at gmail dot com
@ 2020-10-01 13:35 ` mpolacek at gcc dot gnu.org
  2021-06-09  0:46 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-01 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Unfortunately, not yet.  I've taken a look at this, and I think I know what the
problem is, but haven't written a fix yet.

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
  2020-10-01  7:08 ` [Bug c++/89062] class template argument deduction failure with parentheses lisyarus at gmail dot com
  2020-10-01 13:35 ` mpolacek at gcc dot gnu.org
@ 2021-06-09  0:46 ` mpolacek at gcc dot gnu.org
  2021-07-19 12:49 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09  0:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brycelelbach at gmail dot com

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 100979 has been marked as a duplicate of this bug. ***

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-06-09  0:46 ` mpolacek at gcc dot gnu.org
@ 2021-07-19 12:49 ` mpolacek at gcc dot gnu.org
  2021-08-08 17:10 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-07-19 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gareth@ignition-web.co.uk

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 101509 has been marked as a duplicate of this bug. ***

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-07-19 12:49 ` mpolacek at gcc dot gnu.org
@ 2021-08-08 17:10 ` ppalka at gcc dot gnu.org
  2021-08-11 19:59 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-08 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-08-08 17:10 ` ppalka at gcc dot gnu.org
@ 2021-08-11 19:59 ` cvs-commit at gcc dot gnu.org
  2021-08-11 20:03 ` ppalka at gcc dot gnu.org
  2021-10-06 15:18 ` avi@cloudius-systems.com
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:6186708312780bb2139da01946abdde39667e985

commit r12-2859-g6186708312780bb2139da01946abdde39667e985
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Aug 11 15:58:30 2021 -0400

    c++: most vexing parse and braced CTAD [PR89062]

    Here grokdeclarator is emitting the error

      error: class template placeholder âFooâ not permitted in this context

    during the tentative (and ultimately futile) parse of 'x' as a function
    declaration.  This happens because when parsing 'Foo{1}',
    cp_parser_parameter_declaration yields a parameter declaration with no
    declarator and whose type is a CTAD placeholder, and stops short of
    consuming the '{'.  The caller cp_parser_parameter_declaration_list then
    calls grokdeclarator on this declarator, hence the error, and soon
    thereafter we abort this tentative parse since the next token '{'
    doesn't make sense in the context of a parameter list.

    Note that we don't have this issue with parenthesized CTAD

      Foo<int> x(Foo(1));

    because in this case cp_parser_direct_declarator (called indirectly from
    c_p_p_d) consumes the '(' and returns cp_error_declarator instead of a
    NULL declarator (and also simulates a parse error), and grokdeclarator
    exits early for this declarator without emitting any error.

    Since grokdeclarator doesn't take a 'complain' parameter, to fix this we
    need to avoid calling grokdeclarator in this situation.  To that end
    this patch makes c_p_p_d simulate an error when a construct is a CTAD
    expression and definitely not a parameter declaration, so that c_p_p_d_l
    can avoid calling grokdeclarator by checking for this simulated error.
    Alternatively we could keep all this logic inside c_p_p_d_l and not
    touch c_p_p_d at all, but this approach seems slightly less adhoc.

            PR c++/89062

    gcc/cp/ChangeLog:

            * parser.c (cp_parser_parameter_declaration_list): Don't call
            grokdeclarator if cp_parser_error_occurred.
            (cp_parser_parameter_declaration): Simulate an error if we see
            the beginning of a CTAD form, i.e. if we see an opening brace
            after the decl-specifier-seq and the type is a CTAD placeholder.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/class-deduction97.C: New test.

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2021-08-11 19:59 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 20:03 ` ppalka at gcc dot gnu.org
  2021-10-06 15:18 ` avi@cloudius-systems.com
  7 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-11 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |12.0

--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

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

* [Bug c++/89062] class template argument deduction failure with parentheses
       [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2021-08-11 20:03 ` ppalka at gcc dot gnu.org
@ 2021-10-06 15:18 ` avi@cloudius-systems.com
  7 siblings, 0 replies; 8+ messages in thread
From: avi@cloudius-systems.com @ 2021-10-06 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

Avi Kivity <avi@cloudius-systems.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |avi@cloudius-systems.com

--- Comment #11 from Avi Kivity <avi@cloudius-systems.com> ---
Seeing this in 11.2, so asking for a backport.

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

end of thread, other threads:[~2021-10-06 15:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-89062-4@http.gcc.gnu.org/bugzilla/>
2020-10-01  7:08 ` [Bug c++/89062] class template argument deduction failure with parentheses lisyarus at gmail dot com
2020-10-01 13:35 ` mpolacek at gcc dot gnu.org
2021-06-09  0:46 ` mpolacek at gcc dot gnu.org
2021-07-19 12:49 ` mpolacek at gcc dot gnu.org
2021-08-08 17:10 ` ppalka at gcc dot gnu.org
2021-08-11 19:59 ` cvs-commit at gcc dot gnu.org
2021-08-11 20:03 ` ppalka at gcc dot gnu.org
2021-10-06 15:18 ` avi@cloudius-systems.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).