public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type"
@ 2021-07-04 13:12 janpmoeller at gmx dot de
  2021-07-08 21:48 ` [Bug c++/101315] " janpmoeller at gmx dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: janpmoeller at gmx dot de @ 2021-07-04 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101315
           Summary: C++20 lambdas in unevaluated context: erroneously
                    fails with "incomplete type"
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janpmoeller at gmx dot de
  Target Milestone: ---

gcc 11.1 and gcc (trunk) fail to compile the following code with --std=c++20:

(1)
////////////////////////////////////////////////////////////////////////////
#include <concepts>
#include <vector>

template <typename Ptr, std::regular_invocable<int> Fn>
struct foo_t {
  foo_t(Ptr ptr) {}
};

template <typename T>
using alias = foo_t<T, decltype([](int) { return 0; })>;

template <typename T>
auto fun(T const& t) {
  return alias<T>{t};
}

int main() {
  std::vector<int> v;
  auto const error = fun(v);
}
////////////////////////////////////////////////////////////////////////////////

Both versions of gcc state:

<source>: In function 'int main()':
<source>:19:14: error: 'const void error' has incomplete type
   19 |   auto const error = fun(v);
      |              ^~~~~
Compiler returned: 1

The issue seems to somehow be related to the alias. Replacing the definition of
fun() with this code results in successful compilation:
(2)
////////////////////////////////////////////////////////////////////////////
template <typename T>
auto fun(T const& t) {
  return foo_t<T, decltype([](int) { return 0; })>{t};
}
////////////////////////////////////////////////////////////////////////////////

Specifying the return type of fun() explicitly results in a different error:
(3)
////////////////////////////////////////////////////////////////////////////
template <typename T>
auto fun(T const& t) -> alias<T> {
  return alias<T>{t};
}
////////////////////////////////////////////////////////////////////////////////
<source>: In function 'int main()':
<source>:19:22: error: 'fun' was not declared in this scope
   19 |   auto const error = fun(v);
      |                      ^~~
Compiler returned: 1

I believe all three variants to be valid c++20.

clang (trunk) compiles versions (1) and (2) of the code, (3) results in a
frontend crash (I'm going to file a bug report against clang for that as well.
I'll comment it here for reference after I'm done).
Also see this link to godbolt: https://godbolt.org/z/r9GMfxzEo

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

* [Bug c++/101315] C++20 lambdas in unevaluated context: erroneously fails with "incomplete type"
  2021-07-04 13:12 [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" janpmoeller at gmx dot de
@ 2021-07-08 21:48 ` janpmoeller at gmx dot de
  2021-08-03  4:11 ` pinskia at gcc dot gnu.org
  2024-04-13  7:49 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janpmoeller at gmx dot de @ 2021-07-08 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from janpmoeller at gmx dot de ---
Just for reference, the clang bug report is
https://bugs.llvm.org/show_bug.cgi?id=51032.

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

* [Bug c++/101315] C++20 lambdas in unevaluated context: erroneously fails with "incomplete type"
  2021-07-04 13:12 [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" janpmoeller at gmx dot de
  2021-07-08 21:48 ` [Bug c++/101315] " janpmoeller at gmx dot de
@ 2021-08-03  4:11 ` pinskia at gcc dot gnu.org
  2024-04-13  7:49 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03  4:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-03
             Status|UNCONFIRMED                 |NEW

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

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

* [Bug c++/101315] C++20 lambdas in unevaluated context: erroneously fails with "incomplete type"
  2021-07-04 13:12 [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" janpmoeller at gmx dot de
  2021-07-08 21:48 ` [Bug c++/101315] " janpmoeller at gmx dot de
  2021-08-03  4:11 ` pinskia at gcc dot gnu.org
@ 2024-04-13  7:49 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 14 by the recent lambda template patches.

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

end of thread, other threads:[~2024-04-13  7:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 13:12 [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" janpmoeller at gmx dot de
2021-07-08 21:48 ` [Bug c++/101315] " janpmoeller at gmx dot de
2021-08-03  4:11 ` pinskia at gcc dot gnu.org
2024-04-13  7:49 ` pinskia 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).