[Bug c++/98802] New: class template argument deduce guide leads infinite recursive.

2021-01-23 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98802

Bug ID: 98802
   Summary: class template argument deduce guide leads infinite
recursive.
   Product: gcc
   Version: 10.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

code here:
https://godbolt.org/z/8W7dK5

#include 
#include 
using namespace std;

template
struct List {
T head;
List tail;
};

template
struct List {};

template List(T) -> List;
template List(T, List) -> List;

template
using IntList = List;

int main(int argc, char** argv) {
auto list1 = IntList<2>{0, IntList<1>{1, IntList<0>{}}};
auto list2 = List{0, List{1, List{2}}};

return 0;
}


error info:

: In instantiation of 'struct List':
:8:18:   recursively required from 'struct List'
:8:18:   required from 'struct List'
:22:41:   required from here
:8:18: fatal error: template instantiation depth exceeds maximum of 900
(use '-ftemplate-depth=' to increase the maximum)
8 | List tail;
  |  ^~~~
compilation terminated.
Compiler returned: 1

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6)

but it work normal in clang.

[Bug c++/98802] class template argument deduce guide leads infinite recursive.

2021-01-23 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98802

--- Comment #1 from Net Can  ---
g++ -std=c++17 work on but not work on -std=c++2a.

[Bug c++/103358] New: what is the first constructor argument of lambda coroutine promise_type?

2021-11-22 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103358

Bug ID: 103358
   Summary: what is the first constructor argument of lambda
coroutine promise_type?
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

the C++20 standard(N4858) says:
> promise-constructor-arguments is determined as follows: overload resolution 
> is performed on a promise
constructor call created by assembling an argument list with lvalues p1 . . .
pn. If a viable constructor is
found (12.4.3), then promise-constructor-arguments is (p1 , . . . , pn),
otherwise promise-constructor-
arguments is empty.

I tested gcc-12 coroutine feature, when I use the free coroutine function,
arguments are that function, but when I use lambda coroutine, the first
argument looks strange, the rest arguments are the same as lambda.

```cpp
auto test = [](int, char, double) -> task {
co_return;
};

```

the promise_type dumps all arguments type:
```cpp
template
promise_type(T&&... args) {
dump {};
}
```

T = {const&&, int&, char&, double&} here, what is
the type `const&&`?

[Bug c++/103358] what is the first constructor argument of lambda coroutine promise_type?

2021-12-18 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103358

--- Comment #2 from Net Can  ---
(In reply to Iain Sandoe from comment #1)
> There was a long discussion about this between the various WG21 paper
> authors.
> 
> The stated intend was that 'this' pointer and the 'lambda object pointer'
> were intended to be cast to references (to the same type as their pointers).
> 
> This behaviour should be the same between MSVC, clang and GCC (but I fear
> that the amendment did not make C++20 timescale - so we might need a
> coordinated change to remove it from the compilers).
> 
> Does that explain what you are seeing?

yes, I see. thank you for your explanation.

[Bug c++/102229] New: 'decltype(auto)' cannot be cv-qualified

2021-09-07 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229

Bug ID: 102229
   Summary: 'decltype(auto)' cannot be cv-qualified
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

code: https://godbolt.org/z/h833W9v95

it begins at version 11.x.

[Bug c++/102229] [11/12 Regression] 'decltype(auto)' cannot be cv-qualified

2021-09-09 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229

--- Comment #7 from Net Can  ---
here is my use case:
https://github.com/netcan/config-loader/blob/master/include/config-loader/serialize/TypeSerializer.h

the key is
```c++
#define TYPE_SERIALIZER(_type, _typeName) \
struct TypeSerializer \
{ static constexpr decltype(auto) name = _typeName; }

template<> TYPE_SERIALIZER((int8_t), "int8_t"); // (1)

template
TYPE_SERIALIZER((std::vector),
concat("vector<", TypeSerializer::name, ">")); // (2)
```

in case (1), the `name` type is `const char(&)[N]`, but in case(2), the `name`
type is `array[N]`, so I use `decltype(auto)` rather `auto`, becase latter
loses char length info.

I tried `static decltype(auto)` not work because it is defined in class, and
requires `constexpr`.

[Bug c++/102707] New: template coroutine generated code failed

2021-10-12 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102707

Bug ID: 102707
   Summary: template coroutine generated code failed
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: netcan1996 at gmail dot com
  Target Milestone: ---

code: https://godbolt.org/z/f591eaTja

```cpp
#include 
#include 
#include 
#include 

template
struct task {
struct promise_type;
using coro_handle = std::coroutine_handle;

auto operator co_await() && noexcept {
return std::suspend_always{};
}

struct promise_type {
auto initial_suspend() noexcept { return std::suspend_always{}; }
auto final_suspend() noexcept {
return std::suspend_always {};
}
void unhandled_exception() { std::terminate(); }
task get_return_object() noexcept {
return {coro_handle::from_promise(*this)};
}

template
void return_value(U &&result) noexcept {
result_ = std::forward(result);
}

R result_;
};

coro_handle handle_;
};

struct Dummy {};
template
task coro_depth_n(std::vector& result) {
result.push_back(N);
if constexpr (N > 0) {
co_await coro_depth_n(result);
result.push_back(N * 10);
}
co_return Dummy{};
}

void test() {
std::vector result;
auto t = coro_depth_n<4>(result);
}
```

compiled failed message:

: In instantiation of 'task coro_depth_n(std::vector&)
[with long unsigned int N = 4]':
:49:29:   required from here
:44:5: internal compiler error: in tsubst_copy, at cp/pt.c:17314
   44 | co_return Dummy{};
  | ^
0x1ff4db9 internal_error(char const*, ...)
???:0
0x7d54cd fancy_abort(char const*, int, char const*)
???:0
0xa44627 instantiate_decl(tree_node*, bool, bool)
???:0
0xa8714b instantiate_pending_templates(int)
???:0
0x8ec779 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
ASM generation compiler returned: 1
: In instantiation of 'task coro_depth_n(std::vector&)
[with long unsigned int N = 4]':
:49:29:   required from here
:44:5: internal compiler error: in tsubst_copy, at cp/pt.c:17314
   44 | co_return Dummy{};
  | ^
0x1ff4db9 internal_error(char const*, ...)
???:0
0x7d54cd fancy_abort(char const*, int, char const*)
???:0
0xa44627 instantiate_decl(tree_node*, bool, bool)
???:0
0xa8714b instantiate_pending_templates(int)
???:0
0x8ec779 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
Execution build compiler returned: 1

[Bug c++/102707] template coroutine generated code failed

2021-10-12 Thread netcan1996 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102707

--- Comment #1 from Net Can  ---
the code is compiled success in msvc