[Bug c++/99864] New: Abbreviated member function template doesn't compile with default function argument

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

Bug ID: 99864
   Summary: Abbreviated member function template doesn't compile
with default function argument
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: stream009 at gmail dot com
  Target Milestone: ---

I got a strange compile error when I use abbreviated function template and
default function argument on member function.

Compiler version: gcc 10.2
Compiler Exploer Link: https://godbolt.org/z/7cMTP875E

// begin source
class foo
{
public:
int mem_fn(auto a, int b = 0);
};

inline int foo::
mem_fn(auto a, int b/*= 0*/)
{
return a + b;
}

int main()
{
foo x;
x.mem_fn(1);
}
// end source

// begin error message
16:15: error: call to 'int foo::mem_fn(auto:2, int) [with auto:1 = int]' uses
the default argument for parameter 2, which is not yet defined
   16 | x.mem_fn(1);
  |   ^
// end error message

- It does compile if function definition is in the class definition
(https://godbolt.org/z/T3ncebTqz)
- It does compile if function is not member function
(https://godbolt.org/z/o8Wc98xE4)
- It does compile if member function is not function template
(https://godbolt.org/z/vWTxTbjoY)
- It does compile if member function is not abbreviated template function
(https://godbolt.org/z/qqzK9E6qc)

[Bug sanitizer/95137] Sanitizers seem to be missing support for coroutines

2021-05-21 Thread stream009 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95137

stream009  changed:

   What|Removed |Added

 CC||stream009 at gmail dot com

--- Comment #42 from stream009  ---
I got strange compile error when I use coroutine with UBSAN.

The weird thing is error is reported in compile time not runtime.
The code compile fine without UBSAN.

GCC version: 11.1
compile option: -std=c++20 -Wall -Wextra -pedantic-errors -fcoroutines
-fsanitize=undefined
compiler explorer link: https://godbolt.org/z/Yva6b1YTz

It seems error happen only coroutine that doesn't return value (promise has
return_void() defined). I don't get error with coroutine that return value.
(https://godbolt.org/z/3jcvYPcqa)

Let me know if I should report this as separate bug.

=== begin source ===
#include 

struct result
{
struct promise_type
{
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }

result get_return_object() { return {}; }

void return_void() {}

void unhandled_exception() {}
};
};

result error(int i)
{
if (i == 0) {
co_return;
}
}
=== end source ===

=== begin compile error ===
: In function 'void _Z5errori.actor(error(int)::_Z5errori.frame*)':
:21:9: warning: '' may be used uninitialized
[-Wmaybe-uninitialized]
   21 | co_return;
  | ^
:21:9: note: '' was declared here
   21 | co_return;
  | ^
=== end compile error ===

[Bug c++/105766] New: requires std::is_constructible<> reports 'constraint depends on itself' error.

2022-05-29 Thread stream009 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105766

Bug ID: 105766
   Summary: requires std::is_constructible<> reports 'constraint
depends on itself' error.
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: stream009 at gmail dot com
  Target Milestone: ---

GCC reports following error on following code.

|error: satisfaction of atomic constraint 'is_constructible_v [with T =
T]' depends on itself

First of all, I can't decipher the error message. So I guessed, maybe root of
trouble is the fact, at the time of instantiation of template baz (4), although
parameter T = foo::bar is a complete type but its surrounding type foo is not.

- If I uncomment (1), the error goes away, so it seems to become a problem only
when the constraint is on a member function.
- Also the error goes away too if I uncomment (2).
- Most interestingly, error goes away if I comment out (3).
- The code compile without error on clang.

FYI, in real code, foo is thread pool, bar is worker, baz is container.

// code
// https://godbolt.org/z/M48ssEqvr
#include 

template
//requires std::is_constructible_v (1)
struct baz
{
baz() = default;
//template // (2)
baz(int) requires std::is_constructible_v {}
};

struct foo
{
struct bar {
bar() = default;
bar(foo&);// (3)
bar(int);
};
baz m_bars; // (4)
};

int main()
{
foo a; (void)a;
}