public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115358] New: template argument deduction/substitution failed on lambda function
@ 2024-06-05 12:32 dongkyun.s at samsung dot com
  2024-06-05 12:35 ` [Bug c++/115358] " dongkyun.s at samsung dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dongkyun.s at samsung dot com @ 2024-06-05 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115358
           Summary: template argument deduction/substitution failed on
                    lambda function
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dongkyun.s at samsung dot com
  Target Milestone: ---

Hello

Noticed compilation failed with https://godbolt.org/z/8s78YPWs3 example code
starting from GCC-13.

<source>: In lambda function:
<source>:10:12: error: no matching function for call to 'foo(const char [])'
   10 |         foo(STR);
      |         ~~~^~~~~
<source>:2:6: note: candidate: 'template<int N> void foo(const char (&)[N])'
    2 | void foo(const char (&data)[N]) {}
      |      ^~~
<source>:2:6: note:   template argument deduction/substitution failed:
<source>:10:12: note:   mismatched types 'const char [N]' and 'const char []'
   10 |         foo(STR);
      |         ~~~^~~~~
ASM generation compiler returned: 1

Any idea into this failure ?
Thank you in advance !

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

* [Bug c++/115358] template argument deduction/substitution failed on lambda function
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
@ 2024-06-05 12:35 ` dongkyun.s at samsung dot com
  2024-06-05 12:36 ` dongkyun.s at samsung dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dongkyun.s at samsung dot com @ 2024-06-05 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from dongkyun.s at samsung dot com ---
Created attachment 58356
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58356&action=edit
example code

example code

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

* [Bug c++/115358] template argument deduction/substitution failed on lambda function
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
  2024-06-05 12:35 ` [Bug c++/115358] " dongkyun.s at samsung dot com
@ 2024-06-05 12:36 ` dongkyun.s at samsung dot com
  2024-06-05 12:53 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dongkyun.s at samsung dot com @ 2024-06-05 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from dongkyun.s at samsung dot com ---
This might be related with https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106649
applied on GCC-13 but latest clang can build this example though.

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

* [Bug c++/115358] template argument deduction/substitution failed on lambda function
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
  2024-06-05 12:35 ` [Bug c++/115358] " dongkyun.s at samsung dot com
  2024-06-05 12:36 ` dongkyun.s at samsung dot com
@ 2024-06-05 12:53 ` redi at gcc dot gnu.org
  2024-06-05 13:12 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2024-06-05 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 115357 has been marked as a duplicate of this bug. ***

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (2 preceding siblings ...)
  2024-06-05 12:53 ` redi at gcc dot gnu.org
@ 2024-06-05 13:12 ` pinskia at gcc dot gnu.org
  2024-06-05 13:19 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-05 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|template argument           |[13/14/15 Regression]
                   |deduction/substitution      |template argument
                   |failed in generic lambda    |deduction/substitution
                   |function                    |failed in generic lambda
                   |                            |function
   Last reconfirmed|                            |2024-06-05
           Keywords|                            |needs-bisection,
                   |                            |rejects-valid
     Ever confirmed|0                           |1
   Target Milestone|---                         |13.4
             Status|UNCONFIRMED                 |NEW

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (3 preceding siblings ...)
  2024-06-05 13:12 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic " pinskia at gcc dot gnu.org
@ 2024-06-05 13:19 ` pinskia at gcc dot gnu.org
  2024-06-06  6:30 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-05 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note this is not related to NSDMI nor related to use of STR in a non-complete
type context as shown by:
```
template <int N>
void foo(const int (&data)[N]) {}

template <class T>
struct Bar
{
    static constexpr int STR[] = {1,2,3};
    Bar();
};

template<class T>
Bar<T>::Bar()
{
    [](auto){
        foo(STR);
   };
}

int main()
{
    Bar<void>{};
}
```

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (4 preceding siblings ...)
  2024-06-05 13:19 ` pinskia at gcc dot gnu.org
@ 2024-06-06  6:30 ` rguenth at gcc dot gnu.org
  2024-06-17 11:41 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540 jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-06  6:30 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (5 preceding siblings ...)
  2024-06-06  6:30 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size rguenth at gcc dot gnu.org
@ 2024-06-17 11:41 ` jakub at gcc dot gnu.org
  2024-06-18 17:44 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-17 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
            Summary|[13/14/15 Regression]       |[13/14/15 Regression]
                   |template argument           |template argument
                   |deduction/substitution      |deduction/substitution
                   |failed in generic lambda    |failed in generic lambda
                   |function use of static      |function use of static
                   |constexpr array type whos   |constexpr array type whos
                   |initializer defines the     |initializer defines the
                   |size                        |size since r13-2540
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r13-2540-g4db3cb781c355341fa041e6b5bbbfc495c6a0fdb

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (6 preceding siblings ...)
  2024-06-17 11:41 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540 jakub at gcc dot gnu.org
@ 2024-06-18 17:44 ` ppalka at gcc dot gnu.org
  2024-06-25 14:42 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-18 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Non-constexpr testcase exhibiting an even older regression (since
r8-2720-gf44a8dd56f5bfb):

template <int N>
void f(int (&)[N]);

template <class T>
struct A {
  static int STR[];
  A() { [](auto){ f(STR); }; }
};

template<class T>
int A<T>::STR[] = {1,2,3};

A<void> a;

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (7 preceding siblings ...)
  2024-06-18 17:44 ` ppalka at gcc dot gnu.org
@ 2024-06-25 14:42 ` cvs-commit at gcc dot gnu.org
  2024-06-28 21:14 ` cvs-commit at gcc dot gnu.org
  2024-06-28 21:15 ` [Bug c++/115358] [13 " ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-25 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC 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:e3915c1ad56591cbd68229a64c941c38330abd69

commit r15-1614-ge3915c1ad56591cbd68229a64c941c38330abd69
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jun 25 10:42:21 2024 -0400

    c++: using non-dep array var of unknown bound [PR115358]

    For a non-dependent array variable of unknown bound, it seems we need to
    try instantiating its definition upon use in a template context for sake
    of proper checking and typing of the overall expression, like we do for
    function specializations with deduced return type.

            PR c++/115358

    gcc/cp/ChangeLog:

            * decl2.cc (mark_used): Call maybe_instantiate_decl for an array
            variable with unknown bound.
            * semantics.cc (finish_decltype_type): Remove now redundant
            handling of array variables with unknown bound.
            * typeck.cc (cxx_sizeof_expr): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/array37.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (8 preceding siblings ...)
  2024-06-25 14:42 ` cvs-commit at gcc dot gnu.org
@ 2024-06-28 21:14 ` cvs-commit at gcc dot gnu.org
  2024-06-28 21:15 ` [Bug c++/115358] [13 " ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-28 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:33a9c4dd5fcac7e3f5d835b35fe787126339dd2b

commit r14-10357-g33a9c4dd5fcac7e3f5d835b35fe787126339dd2b
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Jun 25 10:42:21 2024 -0400

    c++: using non-dep array var of unknown bound [PR115358]

    For a non-dependent array variable of unknown bound, it seems we need to
    try instantiating its definition upon use in a template context for sake
    of proper checking and typing of the overall expression, like we do for
    function specializations with deduced return type.

            PR c++/115358

    gcc/cp/ChangeLog:

            * decl2.cc (mark_used): Call maybe_instantiate_decl for an array
            variable with unknown bound.
            * semantics.cc (finish_decltype_type): Remove now redundant
            handling of array variables with unknown bound.
            * typeck.cc (cxx_sizeof_expr): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/array37.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>
    (cherry picked from commit e3915c1ad56591cbd68229a64c941c38330abd69)

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

* [Bug c++/115358] [13 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540
  2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
                   ` (9 preceding siblings ...)
  2024-06-28 21:14 ` cvs-commit at gcc dot gnu.org
@ 2024-06-28 21:15 ` ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-06-28 21:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13/14/15 Regression]       |[13 Regression] template
                   |template argument           |argument
                   |deduction/substitution      |deduction/substitution
                   |failed in generic lambda    |failed in generic lambda
                   |function use of static      |function use of static
                   |constexpr array type whos   |constexpr array type whos
                   |initializer defines the     |initializer defines the
                   |size since r13-2540         |size since r13-2540

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

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

end of thread, other threads:[~2024-06-28 21:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05 12:32 [Bug c++/115358] New: template argument deduction/substitution failed on lambda function dongkyun.s at samsung dot com
2024-06-05 12:35 ` [Bug c++/115358] " dongkyun.s at samsung dot com
2024-06-05 12:36 ` dongkyun.s at samsung dot com
2024-06-05 12:53 ` redi at gcc dot gnu.org
2024-06-05 13:12 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic " pinskia at gcc dot gnu.org
2024-06-05 13:19 ` pinskia at gcc dot gnu.org
2024-06-06  6:30 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size rguenth at gcc dot gnu.org
2024-06-17 11:41 ` [Bug c++/115358] [13/14/15 Regression] template argument deduction/substitution failed in generic lambda function use of static constexpr array type whos initializer defines the size since r13-2540 jakub at gcc dot gnu.org
2024-06-18 17:44 ` ppalka at gcc dot gnu.org
2024-06-25 14:42 ` cvs-commit at gcc dot gnu.org
2024-06-28 21:14 ` cvs-commit at gcc dot gnu.org
2024-06-28 21:15 ` [Bug c++/115358] [13 " ppalka at gcc dot gnu.org

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