[Bug c++/99361] New: "unused variable" warning on a used variable in template lambda

2021-03-03 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99361

Bug ID: 99361
   Summary: "unused variable" warning on a used variable in
template lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code:

auto f() {
  const auto x = 1;
  return [] (auto) { return x; };
}

will emit unused variable warnings with "-std=c++20 -Wall" flags:

: In function 'auto f()':
:2:14: warning: variable 'x' set but not used
[-Wunused-but-set-variable]
2 |   const auto x = 1;
  | 

godbolt: https://godbolt.org/z/d54j4G

[Bug c++/99379] New: lambda declared with deduced type 'auto' can appear in its own initializer

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

Bug ID: 99379
   Summary: lambda declared with deduced type 'auto' can appear in
its own initializer
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code accepts by GCC-trunk:

auto x = [x]{ };

godbolt: https://godbolt.org/z/e76Kn1

[Bug c++/99379] lambda declared with deduced type 'auto' can appear in its own initializer

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

--- Comment #1 from 康桓瑋  ---
I find this: 
https://stackoverflow.com/questions/25693676/auto-variable-used-in-lambda-in-its-own-initializer
So this is not a bug.

[Bug c++/99465] New: Segmentation fault when put lambda into requires clause

2021-03-08 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99465

Bug ID: 99465
   Summary: Segmentation fault when put lambda into requires
clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code will trigger the segmentation fault of gcc-trunk:

template 
auto g() requires ([] { return 0; } ());

int main() { g(); }

godbolt: https://godbolt.org/z/4bsaPd



error message:
: In substitution of 'template > auto g() requires
()() [with auto  = 0]':
:4:16:   required from here
:2:6:   required by the constraints of 'template >
auto g() requires ()()'
Segmentation fault
2 | auto g() requires ([] { return 0; } ());
  |   ~~^~~
0x1cee989 internal_error(char const*, ...)
???:0
0x7748f3 pp_cxx_parameter_mapping(cxx_pretty_printer*, tree_node*)
???:0
0x7de235 expr_to_string(tree_node*)
???:0
0x1d0a861 pp_format(pretty_printer*, text_info*)
???:0
0x1ced50a diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
???:0
0x1cee60d error_at(unsigned int, char const*, ...)
???:0
0x73c8ea constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x9510c3 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6db9c2 build_new_function_call(tree_node*, vec**, int)
???:0
0x97d1ec finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8dd92d c_parse_file()
???:0
0xa5bd12 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/99465] Segmentation fault when put lambda into requires clause

2021-03-08 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99465

--- Comment #1 from 康桓瑋  ---
Other related ICE:

template  requires ([]{}());
auto f() requires ([]{}());

https://godbolt.org/z/8z3PPx

[Bug c++/99465] Segmentation fault when put lambda into requires clause

2021-03-08 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99465

--- Comment #2 from 康桓瑋  ---
Here is the minimal reduced example:

f() requires [

godbolt: https://godbolt.org/z/eMWxPj

[Bug c++/99478] New: ICE when decltype lambda in template list

2021-03-08 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99478

Bug ID: 99478
   Summary: ICE when decltype lambda in template list
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code will trigger ICE on gcc-9.1 ~ gcc-trunk with "-std=c++2a"
mode:

template  auto f() {}

int main() { f<{}>(); }

(godbolt: https://godbolt.org/z/dEP5PT)

[Bug c++/99505] New: ICE Segmentation fault when decltype lambda in parameter list

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

Bug ID: 99505
   Summary: ICE Segmentation fault when decltype lambda in
parameter list
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This may be related/duplicated to the 99478, but I am not sure.

The following code will trigger ICE only on gcc-9:

int main() {
  [] (decltype([]{})) {} ({});
}

(godbolt: https://godbolt.org/z/xdr94q)

But this will trigger ICE on gcc-9, gcc-10 and gcc-11:

struct S {
  template 
  operator T() { return {}; }
};

int main() {
  [] (decltype([]{})) {} (S{});
}

(godbolt: https://godbolt.org/z/3dh477)

[Bug c++/99505] ICE Segmentation fault when decltype lambda in parameter list

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

--- Comment #2 from 康桓瑋  ---
Yep, wandbox (https://wandbox.org/permlink/OUJpCz6dFrlA1vod) compiles fine. 

This invalid code maybe can reproduce that locally.

int main() {
  [] (decltype([]{})) {} ();
}

(wandbox: https://wandbox.org/permlink/re9O9DXwoaYmNInd)
(godbolt: https://godbolt.org/z/e4e7or)

[Bug c++/99511] New: default arguments are allowed for parameters of a requires expression

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

Bug ID: 99511
   Summary: default arguments are allowed for parameters of a
requires expression
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code should not be accepted by gcc-10, since default arguments
are not allowed for parameters of a requires expression.

template 
concept C = requires (T = {}) { true; };

(goldbot: https://godbolt.org/z/fM88qb)

[Bug c++/99513] New: ICE Segmentation fault when decltype lambda in concept template list

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

Bug ID: 99513
   Summary: ICE Segmentation fault when decltype lambda in concept
template list
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This may be related/duplicated to the 99505, but I am not sure.

The following invalid code will trigger Segmentation fault on gcc-10 and
gcc-11:

template  concept C = true;
auto f() requires C<{}>;

(wandbox: https://wandbox.org/permlink/1gwi5zWcrICysV5G)
(godbolt: https://godbolt.org/z/PMYz6e)

[Bug c++/99516] New: Erroneous lambda conversion in default non-type template list

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

Bug ID: 99516
   Summary: Erroneous lambda conversion in default non-type
template list
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

GCC 9, 10, 11 rejects the following code:

template  
struct S {};

S<> s;

(godbolt: https://godbolt.org/z/Gs4776)

[Bug c++/99521] New: ICE Segmentation fault when decltype lambda in requires clause

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

Bug ID: 99521
   Summary: ICE Segmentation fault when decltype lambda in
requires clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This may be related/duplicated to the 99513, but I am not sure.

The following invalid code will trigger Segmentation fault on gcc-11:

int main() {
  [](auto) requires (decltype;
}

(godbolt: https://godbolt.org/z/WaP6qe)

[Bug c++/99521] ICE Segmentation fault when decltype lambda in requires clause

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

康桓瑋  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from 康桓瑋  ---
This is duplicate of 99465.

*** This bug has been marked as a duplicate of bug 99465 ***

[Bug c++/99465] Segmentation fault when put lambda into requires clause

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

--- Comment #3 from 康桓瑋  ---
*** Bug 99521 has been marked as a duplicate of this bug. ***

[Bug c++/99361] "unused variable" warning on a used variable in template lambda

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

康桓瑋  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|NEW |RESOLVED

--- Comment #2 from 康桓瑋  ---
This is a duplicate of 96311.

*** This bug has been marked as a duplicate of bug 96311 ***

[Bug c++/96311] [8/9/10/11 Regression] false positive for -Wunused-but-set-variable (const/constexpr identifier used in generic lambda)

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

康桓瑋  changed:

   What|Removed |Added

 CC||hewillk at gmail dot com

--- Comment #5 from 康桓瑋  ---
*** Bug 99361 has been marked as a duplicate of this bug. ***

[Bug c++/99538] New: ICE when lambda return requires clause

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

Bug ID: 99538
   Summary: ICE when lambda return requires clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code will trigger the ICE of gcc-10 and trunk:


int main(){
  [] { return requires { []{}; }; };
}

(godbolt: https://godbolt.org/z/WGjx9h)

[Bug c++/99539] New: Varargs are allowed in requires expression

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

Bug ID: 99539
   Summary: Varargs are allowed in requires expression
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

gcc-trunk accepts the following code:

template
concept C = requires(T t, ...) {// error: terminates with an ellipsis
  t;
};

(goldbot: https://godbolt.org/z/qbz7b9)

but according to [expr.prim#req.general-4]: "The parameter-declaration-clause
of a requirement-parameter-list shall not terminate with an ellipsis."

[Bug c++/99546] New: Weird return value of C++20 requires expression

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

Bug ID: 99546
   Summary: Weird return value of C++20 requires expression
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

gcc-trunk accepts following code:

int main() {
  constexpr auto b = requires { []{}; };
  static_assert(b);
  static_assert(!b);
}

(godbolt: https://godbolt.org/z/4K5vq8)

[Bug c++/99546] Weird return value of C++20 requires expression

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

--- Comment #1 from 康桓瑋  ---
You can see more weird cases in this: 
https://stackoverflow.com/questions/66578966/weird-return-value-of-c20-requires-expression.

[Bug c++/99583] New: Parameter packs not expanded in lambda noexcept specifier

2021-03-14 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99583

Bug ID: 99583
   Summary: Parameter packs not expanded in lambda noexcept
specifier
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following valid code failed since gcc-4.7

void f(...);

template  
void g() {  
 f([]() noexcept(B) {} ...);  
}

(goldbot: https://gcc.godbolt.org/z/WoKaab)

[Bug c++/99584] New: ICE Segmentation fault when expanding lambda noexcept specifier with invalid parameter pack

2021-03-14 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99584

Bug ID: 99584
   Summary: ICE Segmentation fault when expanding lambda noexcept
specifier with invalid parameter pack
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This may be related/duplicated to PR 99513 or PR 99583, but I am not sure.

The following invalid code triggers ICE in gcc-trunk:


void f(...);

template  
void g(Args... args) {  
 f([](Args) noexcept(args) {} ...);  
}

int main() { g(0); }

(godbolt: https://gcc.godbolt.org/z/477Mn8)
(wandbox: https://wandbox.org/permlink/qA74qnIHdaZSX6JF)

[Bug c++/99589] New: lambda init-capture without initializer in C++20

2021-03-14 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99589

Bug ID: 99589
   Summary: lambda init-capture without initializer in C++20
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

gcc-9 should reject this code:

void f(auto... args) {  
  ([...args]{}, ...); 
}

according to [expr.prim.lambda#nt:init-capture], the "...args" in capture list
must follow by a initializer.

(goldbot: https://godbolt.org/z/eMo7aY)

[Bug c++/99590] New: ICE when pack expansion with lambda

2021-03-15 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99590

Bug ID: 99590
   Summary: ICE when pack expansion with lambda
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code will trigger ICE on gcc-8 ~ gcc-trunk with "-std=c++2a"
mode:

void g(auto... args) {
  ([args...](auto){}(args), ...);  
}

int main() { g(0, 1); }

(goldbot: https://godbolt.org/z/Tvzj7b)

[Bug c++/99590] ICE when pack expansion with lambda

2021-03-15 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99590

--- Comment #1 from 康桓瑋  ---
I think this is a valid code:

void g(auto... args) {
  ([args...](auto...){}(args   ), ...);
}

void f(auto... args) {
  ([args   ](auto...){}(args...), ...);
}

int main() { 
  g(0, 1); // this one ICE
  f(0, 1); // this one works
}

[Bug c++/99594] New: Parameter packs not expanded in lambda requires clause

2021-03-15 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99594

Bug ID: 99594
   Summary: Parameter packs not expanded in lambda requires clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Same form with PR 99583, this code should work:

template 
auto f() {
  ([](auto) requires (B) {}, ...);
}

(goldbot: https://godbolt.org/z/jdn4je)

[Bug c++/99595] New: ICE when pack expansion with template lambda

2021-03-15 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99595

Bug ID: 99595
   Summary: ICE when pack expansion with template lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code will trigger ICE on gcc-trunk:

auto f(auto... args) {
  ([]{ y; }, ...);
}

int main() { f(0); }

(godbolt: https://godbolt.org/z/11G8G5)
(wanbox: https://wandbox.org/permlink/Bbmq4ZWehhJqlBdk)

[Bug c++/99597] New: Parameter packs not expanded in lambda template list

2021-03-15 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99597

Bug ID: 99597
   Summary: Parameter packs not expanded in lambda template list
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code intends to work, even if it fails in three major compilers:

template  
void f(Ts...) {
  ([](){}, ...);  
}

int main() { f(0, 0.5); }

(goldbot: https://godbolt.org/z/xnM9dY)

[Bug c++/99628] New: g++ fails to do the implicit conversion when rewritten operator<=>

2021-03-17 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99628

Bug ID: 99628
   Summary: g++ fails to do the implicit conversion when rewritten
operator<=>
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

gcc-trunk rejects this valid code:

struct S{
  operator int() { return 0; }
};

auto operator<=>(S, S) { return S{}; }

int main() {
  return S{} < S{};
}

(godbolt://godbolt.org/z/9ah1xE)


The expression S{} < S{} would be rewritten as (S{} <=> S{}) < 0, since the
(S{} <=> S{}) return S{}, we compare S{} with 0, and S{} explicit convert to 0,
so we compare 0 < 0 which is false, but gcc-trunk rejects with:

:8:14: error: no match for 'operator<' (operand types are 'S' and
'int')
8 |   return S{} < S{};

[Bug c++/99589] lambda init-capture without initializer in C++20

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

--- Comment #1 from 康桓瑋  ---
reduced:

auto f(auto x) {
 [...x]{};
}

[Bug c++/99659] New: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'error_mark' in synthesize_implicit_template_parm, at cp/parser.c:45415

2021-03-19 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99659

Bug ID: 99659
   Summary: internal compiler error: tree check: expected tree
that contains 'decl common' structure, have
'error_mark' in synthesize_implicit_template_parm, at
cp/parser.c:45415
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/qePTPh


template <...args> bar(auto);


:1:11: error: expected identifier before '...' token
1 | template <...args> bar(auto);
  |   ^~~
:1:24: internal compiler error: tree check: expected tree that contains
'decl common' structure, have 'error_mark' in
synthesize_implicit_template_parm, at cp/parser.c:45415
1 | template <...args> bar(auto);
  |^~~~
0x1cfa259 internal_error(char const*, ...)
???:0
0x67bb5d tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0x8e136d c_parse_file()
???:0
0xa5f962 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/99672] New: std::source_location yield different column numbers between free function and template functions

2021-03-19 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99672

Bug ID: 99672
   Summary: std::source_location yield different column numbers
between free function and template functions
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/8T3MGv



#include 
#include 

auto g(auto...) {
std::cout << std::source_location::current().column() << "\n";
}

auto f() {
std::cout << std::source_location::current().column() << "\n";
}

int main() {
g();
f();
std::cout << std::source_location::current().column() << "\n";
}



GCC-trunk output 43, 44, and 44, but the first one should be 44.

[Bug c++/99678] New: c++20 trailing requires clauses allows undeclared identifier

2021-03-19 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99678

Bug ID: 99678
   Summary: c++20 trailing requires clauses allows undeclared
identifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/reG8qE



void bar(auto) requires undeclared_identifier;



GCC accepts this code.

[Bug c++/99546] Weird return value of C++20 requires expression

2021-03-20 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99546

--- Comment #4 from 康桓瑋  ---
same form, but this will trigger ICE:



struct S{
  constexpr static auto s = requires { []; };
};



:1:8: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in override_type_for_decl_p, at dwarf2out.c:23786
1 | struct S{
  |^
0x1cfa229 internal_error(char const*, ...)
???:0
0x67b5e5 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xf3666f rest_of_type_compilation(tree_node*, int)
???:0
0x70c969 finish_struct_1(tree_node*)
???:0
0x70e754 finish_struct(tree_node*, tree_node*)
???:0
0x8e121d c_parse_file()
???:0
0xa5f812 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/99672] std::source_location yield different column numbers between free function and template functions

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

--- Comment #3 from 康桓瑋  ---
I think the issue of line() function also needs to do a patch.

https://godbolt.org/z/q8EPnG


constexpr int g(auto...) {
return std::source_location::current( // < opening paren line number
).line();
}

constexpr int f() {
return std::source_location::current( 
).line(); // < closing paren line number
}



[Bug c++/99700] New: gcc takes an uninitialized variable as a constant expression

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

Bug ID: 99700
   Summary: gcc takes an uninitialized variable as a constant
expression
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/93qM1b



struct A {
  constexpr A() { c[0] = 0; }
  char c[2];
};

constexpr A a;



[Bug c++/99730] New: gcc cannot choose the best overload resolution with constrained function

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

Bug ID: 99730
   Summary: gcc cannot choose the best overload resolution with
constrained function
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

auto f(auto&&...) {}
auto f(auto...) requires true {}

int main() {
  f();
}


gcc reject with:

:5:5: error: call of overloaded 'f()' is ambiguous
5 |   f();
  | ^

https://godbolt.org/z/e8jas5frc

[Bug c++/99732] New: gcc accepts overload a member function without ref-qualifier with a member function with a ref-qualifier

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

Bug ID: 99732
   Summary: gcc accepts overload a member function without
ref-qualifier with a member function with a
ref-qualifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

struct S {
  constexpr auto f(auto...) &&{ return false; }
  constexpr auto f(auto...) requires true { return true;  }
};

static_assert(S{}.f());

gcc accepts this code.

https://godbolt.org/z/7rdWEsrfv

[Bug c++/99730] gcc cannot choose the best overload resolution with constrained function

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

--- Comment #3 from 康桓瑋  ---
Really appreciate your reply and explanation.

[Bug c++/99742] New: Parameter packs not expanded with nested requirements

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

Bug ID: 99742
   Summary: Parameter packs not expanded with nested requirements
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

template 
concept C = (requires { requires B; } && ...);

static_assert(C);


gcc rejects this code.
https://godbolt.org/z/c6sEq5KEs

[Bug c++/99743] New: ICE Segmentation fault when use lambda init-capture in requires clause

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

Bug ID: 99743
   Summary: ICE Segmentation fault when use lambda init-capture in
requires clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

static_assert(requires { [x = 0]{}; });

https://godbolt.org/z/n9KE4z7P6

I don't know whether this code is well-form or not.
Maybe related/duplicate to PR 99538, PR 99465, PR 99546 since they are the same
form.

[Bug c++/99745] New: ICE when parameter pack not expanded in bit field

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

Bug ID: 99745
   Summary: ICE when parameter pack not expanded in bit field
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/dz1bcxhYf

template 
struct S { 
  int a : sizeof(Ts); 
};

S s;


:3:11: internal compiler error: in dependent_type_p, at cp/pt.c:26775
3 |   int a : sizeof(Ts);
  |   ^~
0x1cfa409 internal_error(char const*, ...)
???:0
0x6ba5f7 fancy_abort(char const*, int, char const*)
???:0
0x8f91c8 dependent_type_p(tree_node*)
???:0
0x9c3a1f cxx_sizeof_or_alignof_type(unsigned int, tree_node*, tree_code, bool,
bool)
???:0
0x9164a7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x95a1a6 instantiate_class_template(tree_node*)
???:0
0x7b2bd0 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8e111d c_parse_file()
???:0
0xa5f9c2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/99745] ICE when parameter pack not expanded in bit field

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

--- Comment #1 from 康桓瑋  ---
Reduce a little:

template 
struct S {
  int x : Xs;
};

S s;


:3:7: internal compiler error: unexpected expression 'Xs' of kind
template_parm_index
3 |   int x : Xs;
  |   ^

[Bug c++/99750] New: gcc allow operator literal operator have default parameters

2021-03-24 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99750

Bug ID: 99750
   Summary: gcc allow operator literal operator have default
parameters
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

constexpr auto operator""_s(const char*, unsigned long size = 2) {
  return size;
}
static_assert(operator""_s(nullptr) == 2);

https://godbolt.org/z/x3YjPT8vd

[Bug libstdc++/99752] New: ranges::find_end should return empty subrange when search range is empty

2021-03-24 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99752

Bug ID: 99752
   Summary: ranges::find_end should return empty subrange when
search range is empty
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

In ranges::find_end implementation:

674 else
675   {
676 auto __i = ranges::next(__first1, __last1);
677 if (__first2 == __last2)
678   return {__i, __i};

when the examined range is not bidirectional_range and the search range is
empty, we still do the ranges::next call, this makes the following code
infinite loop:

#include 
#include 

int main() {
  auto r = std::views::iota(0);
  std::ranges::empty_view e;
  std::ranges::find_end(r, e);
}

But according to the [alg.find.end]: "i be last1 if [first2, last2) is empty", 
so I think this is a library bug since in such case ranges::find_end never
return.

Same situations in ranges::rotate with performance loss in more rare
conditions:

1573  {
1574auto __lasti = ranges::next(__first, __last);
1575if (__first == __middle)
1576  return {__lasti, __lasti};
1577if (__last == __middle)
1578  return {std::move(__first), std::move(__lasti)};

[Bug libstdc++/99752] ranges::find_end should return empty subrange when search range is empty

2021-03-24 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99752

--- Comment #1 from 康桓瑋  ---
My pardon, since the ranges::find_end return type is ranges::subrange, we
still to get the common last1 iterator through the ranges::next call, so this
seems not a bug.

[Bug libstdc++/99752] ranges::find_end should return empty subrange when search range is empty

2021-03-24 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99752

康桓瑋  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from 康桓瑋  ---
Since the ranges::find_end return type is ranges::subrange, we still to get
the common last1 iterator through the ranges::next call, so this seems not a
bug.

[Bug c++/99757] New: ICE when parameter pack not expanded with static_data_member

2021-03-24 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99757

Bug ID: 99757
   Summary: ICE when parameter pack not expanded with
static_data_member
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

related to PR 99745:

template 
struct S {
  constexpr static auto x = Ts::x;
};

S s;

:3:25: internal compiler error: in cp_finish_decl, at cp/decl.c:7736
3 |   constexpr static auto x = Ts::x;
  | ^
0x1cfa799 internal_error(char const*, ...)
???:0
0x6ba647 fancy_abort(char const*, int, char const*)
???:0
0x7b2e42 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x91c9df instantiate_decl(tree_node*, bool, bool)
???:0
0x7b31d8 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x7c9d03 finish_static_data_member_decl(tree_node*, tree_node*, bool,
tree_node*, int)
???:0
0x95a530 instantiate_class_template(tree_node*)
???:0
0x7b2bf0 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8e12cd c_parse_file()
???:0
0xa5fb72 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/99800] New: ICE Segmentation fault when put lambda in template parameter list

2021-03-27 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99800

Bug ID: 99800
   Summary: ICE Segmentation fault when put lambda in template
parameter list
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/b6cnKo7ej

template  struct A {};
template  struct B {};
template  using b = B<[]{ return a; }()>;



:3:45: internal compiler error: Segmentation fault
3 | template  using b = B<[]{ return a; }()>;
  | ^
0x1cfb7f9 internal_error(char const*, ...)
???:0
0x6c42c5 resolve_args(vec*, int)
???:0
0x909251 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x929663 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x97fb6d finish_template_type(tree_node*, tree_node*, int)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,

[Bug c++/99803] New: internal compiler error: in make_typename_type, at cp/decl.c:4057

2021-03-28 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99803

Bug ID: 99803
   Summary: internal compiler error: in make_typename_type, at
cp/decl.c:4057
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/4Yfnfzdhe

struct A {  A(auto); };
A(unsigned) -> A:: template A;

[Bug c++/99806] New: ICE in tsubst_copy of gcc-trunk and tree_code_size of gcc-10

2021-03-28 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99806

Bug ID: 99806
   Summary: ICE in tsubst_copy of gcc-trunk and tree_code_size of
gcc-10
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/s687ePeGG


template  concept C = requires (T a) { a.f(0); };
struct S { void f(auto) noexcept(); };
static_assert(C);


gcc-trunk:

:2:17: internal compiler error: in tsubst_copy, at cp/pt.c:17247
2 | struct S { void f(auto) noexcept(); };
  | ^

gcc-10:

:2:17: internal compiler error: in tree_code_size, at tree.c:910
2 | struct S { void f(auto) noexcept(); };
  |

[Bug c++/99809] New: ICE: sorry, unimplemented: unexpected AST of kind nontype_argument_pack

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99809

Bug ID: 99809
   Summary: ICE: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/4dnnTTzMW

#include 

auto f(auto... args) {
  return [](std::same_as auto) {};
}

int main() {
  f(0)(0);
}

:4:10: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
4 |   return [](std::same_as auto) {};
  |  ^~~~
:4:10: internal compiler error: in potential_constant_expression_1, at
cp/constexpr.c:8854
0x1cfb7f9 internal_error(char const*, ...)
???:0
0x6ba871 fancy_abort(char const*, int, char const*)
???:0
0x72ac1e is_nondependent_constant_expression(tree_node*)
???:0
0x91465c instantiate_non_dependent_expr_sfinae(tree_node*, int)
???:0
0x98afc1 finish_decltype_type(tree_node*, bool, int)
???:0
0x915dc3 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x941bb6 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0x739946 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
???:0
0x949a91 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91c84f instantiate_decl(tree_node*, bool, bool)
???:0
0x7c6c0e maybe_instantiate_decl(tree_node*)
???:0
0x7c8370 mark_used(tree_node*, int)
???:0
0x6de097 build_new_function_call(tree_node*, vec**, int)
???:0
0x980c6c finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99811] New: ICE: tree check: accessed elt 2 of 'tree_vec' with 1 elts in tsubst_pack_expansion, at cp/pt.c:13002

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99811

Bug ID: 99811
   Summary: ICE: tree check: accessed elt 2 of 'tree_vec' with 1
elts in tsubst_pack_expansion, at cp/pt.c:13002
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/shj7Tr65M

related to PR 99809:

#include 

template 
auto f(Ts...) {
  return [](std::same_as auto...) {};
}

int main() {
  f(0, 0.5)();
}

:9:12: internal compiler error: tree check: accessed elt 2 of
'tree_vec' with 1 elts in tsubst_pack_expansion, at cp/pt.c:13002
9 |   f(0, 0.5)();
  |   ~^~
0x1cfb7f9 internal_error(char const*, ...)
???:0
0x67bcb2 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
???:0
0x93095c tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0x73efca constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x954963 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6e225e build_op_call(tree_node*, vec**, int)
???:0
0x980ae5 finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

[Bug c++/99811] ICE: tree check: accessed elt 2 of 'tree_vec' with 1 elts in tsubst_pack_expansion, at cp/pt.c:13002

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99811

--- Comment #1 from 康桓瑋  ---
same form with the different error message:

https://godbolt.org/z/hE9n6eEMT

#include 

template 
auto f(Ts...) {
  return [] auto> {};
}

int main() {
  f(0).template operator()<0>();
}


:9:30: internal compiler error: tree check: accessed elt 1 of
'tree_vec' with 0 elts in hash, at cp/constraint.cc:2522
9 |   f(0).template operator()<0>();
  |   ~~~^~
0x1cfb7f9 internal_error(char const*, ...)
???:0
0x67bcb2 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
???:0
0x73fc50 sat_hasher::hash(sat_entry*)
???:0
0x73b2b7 satisfaction_cache::satisfaction_cache(tree_node*, tree_node*,
sat_info)
???:0
0x73efca constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x909bbe do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x954187 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6dec99 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99800] ICE Segmentation fault when put lambda in template parameter list

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99800

康桓瑋  changed:

   What|Removed |Added

   Keywords|ice-on-invalid-code |ice-on-valid-code

--- Comment #1 from 康桓瑋  ---
This is a valid code.

[Bug c++/99815] New: ICE: in placeholder_type_constraint_dependent_p, at cp/pt.c:28193

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99815

Bug ID: 99815
   Summary: ICE: in placeholder_type_constraint_dependent_p, at
cp/pt.c:28193
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/4vx18beMW

template  concept C = true;

template 
auto bar(Ts...) { C auto x = 0; }



:4:37: internal compiler error: in
placeholder_type_constraint_dependent_p, at cp/pt.c:28193
4 | auto bar(Ts...) { C auto x = 0; }
  | ^
0x1cfb7f9 internal_error(char const*, ...)
???:0
0x6ba871 fancy_abort(char const*, int, char const*)
???:0
0x90a81a do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x7b1dd4 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99809] ICE: sorry, unimplemented: unexpected AST of kind nontype_argument_pack

2021-03-29 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99809

--- Comment #2 from 康桓瑋  ---
I think this is not a valid code even if clang accepts it, since the parameter
packs args are not expanded.

[Bug c++/99831] New: ICE: in reshape_init, at cp/decl.c:6720

2021-03-30 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99831

Bug ID: 99831
   Summary: ICE: in reshape_init, at cp/decl.c:6720
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This is a complicated one since I don't know how to reduce it.

https://godbolt.org/z/rqTGxMWef

#include 

template 
struct StringLiteral {
  constexpr StringLiteral(const char (&str)[N]) {
std::ranges::copy_n(str, N, value);
  }
  char value[N];
};

template 
struct string{
  constexpr bool operator==(const string&) const noexcept = default;
};

template 
constexpr auto operator+(string, string) {
  constexpr auto L3 = []{
constexpr auto size1 = sizeof(L1.value);
constexpr auto size2 = sizeof(L2.value);
char value[size1 + size2 - 1] = {};
std::ranges::sort(value);
std::ranges::copy_n(L1.value, size1, value);
std::ranges::copy_n(L2.value, size2, value + size1 - 1);
return StringLiteral{value};
  }();
  return string{};
}

static_assert(
  string<"hello, world">{} ==
  string<"hello">{} + string<", world">{}
);

static_assert(
  string<"a rose is a rose is a rose">{} ==
  string<"a rose">{} + string<" is ">{} + 
  string<"a rose">{} + string<" is ">{} + 
  string<"a rose">{}
);

:36:40: internal compiler error: in reshape_init, at cp/decl.c:6720
   36 |   string<"a rose is a rose is a rose">{} ==
  |^
0x1cfb6a9 internal_error(char const*, ...)
???:0
0x6ba871 fancy_abort(char const*, int, char const*)
???:0
0x7810b6 reshape_init(tree_node*, tree_node*, int)
???:0
0x97e050 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99831] ICE: in reshape_init, at cp/decl.c:6720

2021-03-30 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99831

--- Comment #1 from 康桓瑋  ---
Note that if we comment one of the asserts, there will be no problem, or we
just comment the redundant std::ranges::sort.

[Bug c++/99831] ICE: in reshape_init, at cp/decl.c:6720

2021-03-30 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99831

--- Comment #4 from 康桓瑋  ---
When the array subscript is outside the bounds of array, gcc seems to fall into
infinite recursion due to the default operator==.

Here is the reduced with no header:

struct A {
  constexpr A(const char*) {}
  char value[1] = {};
};

template 
struct B {
  constexpr bool operator==(const B&) const = default;
};

constexpr auto foo(auto) {
  constexpr auto a = [] {
char value[1];
value[2] = 0; // this line
return A{value};
  }();
  return B{};
}

constexpr auto b = foo(B<"">{});

: In instantiation of 'struct B< >':
:8:18:   recursively required from 'struct B< >'
:8:18:   required from 'struct B< >'
:17:15:   required from 'constexpr auto foo(auto:1) [with auto:1 =
B]'
:20:23:   required from here
:8:18: fatal error: template instantiation depth exceeds maximum of 900
(use '-ftemplate-depth=' to increase the maximum)
8 |   constexpr bool operator==(const B&) const = default;
  |  ^~~~
compilation terminated.

[Bug c++/99844] New: ICE: unexpected expression 'B' of kind template_parm_index

2021-03-30 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99844

Bug ID: 99844
   Summary: ICE: unexpected expression 'B' of kind
template_parm_index
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Related to fixed PR 99745 and PR 99757.

https://godbolt.org/z/5qW5a1Mnq

template 
struct S {
  constexpr explicit(B) S() {}
};

constexpr S s;


:3:25: internal compiler error: unexpected expression 'B' of kind
template_parm_index
3 |   constexpr explicit(B) S() {}
  | ^
0x1cfb6a9 internal_error(char const*, ...)
???:0
0x9164c7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x959fc9 instantiate_class_template(tree_node*)
???:0
0x77fbc7 start_decl_1(tree_node*, bool)
???:0
0x7a728f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0x8e12ad c_parse_file()
???:0
0xa600a2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99809] ICE: sorry, unimplemented: unexpected AST of kind nontype_argument_pack

2021-03-31 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99809

--- Comment #3 from 康桓瑋  ---
More reduced:

template 
concept C = true;

void f(auto... args) {
  [](C auto) {};
}

int main() { f(); }

[Bug c++/99848] New: Parameter packs not expanded in type-constraint placeholder

2021-03-31 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99848

Bug ID: 99848
   Summary: Parameter packs not expanded in type-constraint
placeholder
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/hxed4eorx

template 
concept C = false;

template 
auto f(Ts...) {
  ([](C auto){}, ...);
}

gcc rejects it.

[Bug c++/99850] New: [P1102R2] reject valid lambda syntax in C++23

2021-03-31 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850

Bug ID: 99850
   Summary: [P1102R2] reject valid lambda syntax in C++23
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/x5E5cGPTb

auto l = [] requires true -> void {};

gcc incorrectly rejects this valid lambda, you can see more details in
https://stackoverflow.com/questions/6684/the-validity-of-lambda-expression-with-omitted-parameter-list-in-c23

[Bug c++/99850] [P1102R2] reject valid lambda syntax in C++23

2021-03-31 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99850

--- Comment #4 from 康桓瑋  ---
This ICE may be caused by not handle this form.

template  concept C = true;

auto l = [] requires (C && ...) -> void {};

https://godbolt.org/z/vo8xPd4hY

:3:48: internal compiler error: Segmentation fault
3 | auto l = [] requires (C && ...) -> void {};
  |^~~
0x1cfca39 internal_error(char const*, ...)
???:0
0x940286 convert_generic_types_to_packs(tree_node*, int, int)
???:0
0x8e126d c_parse_file()
???:0
0xa60292 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99869] New: ICE: in do_auto_deduction, at cp/pt.c:29620

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

Bug ID: 99869
   Summary: ICE: in do_auto_deduction, at cp/pt.c:29620
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This is a small variant of fixed PR 99815.

https://godbolt.org/z/jezs4qh3E

template  concept C = true;

template 
auto bar(Ts...) { for (C auto c : ""); }

:4:42: internal compiler error: in do_auto_deduction, at cp/pt.c:29620
4 | auto bar(Ts...) { for (C auto c : ""); }
  |  ^~
0x1cfca39 internal_error(char const*, ...)
???:0
0x6ba92b fancy_abort(char const*, int, char const*)
???:0
0x90a724 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x8e126d c_parse_file()
???:0
0xa60292 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99874] New: ICE Segmentation fault when declared variable template of template lambda

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

Bug ID: 99874
   Summary: ICE Segmentation fault when declared variable template
of template lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/4fxhP6jf9

template 
auto l = [] requires requires { x; } {};

int main() {
  l<0>.template operator()<0>();
}


:2:40: internal compiler error: Segmentation fault
2 | auto l = [] requires requires { x; } {};
  |^
0x1cfca39 internal_error(char const*, ...)
???:0
0x917a92 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x73f042 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x73f08a constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x954d48 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6ded59 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int)
???:0
0x8e126d c_parse_file()
???:0
0xa60292 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99897] New: ICE Segmentation fault when operator appear in template parameter-list

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

Bug ID: 99897
   Summary: ICE Segmentation fault when operator appear in
template parameter-list
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/fjx8cG995

template  struct A {};
template  struct S { void foo(S<+a>); };


:2:40: internal compiler error: Segmentation fault
2 | template  struct S { void foo(S<+a>); };
  |^
0x1cfd119 internal_error(char const*, ...)
???:0
0x6c4475 resolve_args(vec*, int)
???:0
0x9093b1 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x929803 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x97ff1d finish_template_type(tree_node*, tree_node*, int)
???:0
0x8e140d c_parse_file()
???:0
0xa606f2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99899] New: ICE: in do_auto_deduction, at cp/pt.c:29630

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

Bug ID: 99899
   Summary: ICE: in do_auto_deduction, at cp/pt.c:29630
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

This is a small variant of fixed PR 99815, PR 99869.

https://godbolt.org/z/zrnPqdenx

template  concept C = true;

struct S { int a, b; };

template 
auto bar(Ts...) { C auto [a, b] = S{}; }


: In function 'auto bar(Ts ...)':
:6:44: internal compiler error: in do_auto_deduction, at cp/pt.c:29630
6 | auto bar(Ts...) { C auto [a, b] = S{}; }
  |^
0x1cfd119 internal_error(char const*, ...)
???:0
0x6baa1b fancy_abort(char const*, int, char const*)
???:0
0x90a8c4 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x7b1e34 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8e140d c_parse_file()
???:0
0xa606f2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99904] New: ICE: in tsubst_pack_expansion, at cp/pt.c:13056

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

Bug ID: 99904
   Summary: ICE: in tsubst_pack_expansion, at cp/pt.c:13056
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

maybe dup of PR 99595.

https://godbolt.org/z/zarsP11Y6

template  concept C = true;
template  struct A {};
template  class>
struct S {};
constexpr S s;


:5:14: internal compiler error: in tsubst_pack_expansion, at
cp/pt.c:13056
5 | constexpr S s;
  |  ^
0x1cfcc99 internal_error(char const*, ...)
???:0
0x6baa77 fancy_abort(char const*, int, char const*)
???:0
0x9305c7 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0x739b56 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
???:0
0x739cd1 tsubst_constraint_info(tree_node*, tree_node*, int, tree_node*)
???:0
0x929233 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x97fa1d finish_template_type(tree_node*, tree_node*, int)
???:0
0x8e14fd c_parse_file()
???:0
0xa601f2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99909] New: The value of 'std::is_integral_v' is not usable in a constant expression

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

Bug ID: 99909
   Summary: The value of 'std::is_integral_v' is not usable
in a constant expression
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/jWr39rrsT

#include 

template  
struct S {};

template  class>
constexpr auto f() {}

int main() {
  f();
}

gcc rejects this code with:

In file included from :1:
/opt/compiler-explorer/gcc-trunk-20210404/include/c++/11.0.1/concepts:102:13:  
required for the satisfaction of 'integral, >]>' [with auto [requires
std::integral<, >] = auto [requires std::integral<,
>]]
/opt/compiler-explorer/gcc-trunk-20210404/include/c++/11.0.1/concepts:102:24:
error: the value of 'std::is_integral_v, >]>' is not usable in a constant expression
  102 | concept integral = is_integral_v<_Tp>;
  |^~
In file included from
/opt/compiler-explorer/gcc-trunk-20210404/include/c++/11.0.1/concepts:44,
 from :1:
/opt/compiler-explorer/gcc-trunk-20210404/include/c++/11.0.1/type_traits: In
function 'int main()':
/opt/compiler-explorer/gcc-trunk-20210404/include/c++/11.0.1/type_traits:3026:25:
note: 'std::is_integral_v, >]>' used
in its own initializer
 3026 |   inline constexpr bool is_integral_v = is_integral<_Tp>::value;
  | ^

[Bug c++/99916] New: ICE Segmentation fault when erroneous structured bindings appears in requires-clause

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

Bug ID: 99916
   Summary: ICE Segmentation fault when erroneous structured
bindings appears in requires-clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/cW8367TTr

struct S {} s;
template  concept C = requires { [a] = s; };
static_assert(C);


:2:41: internal compiler error: Segmentation fault
2 | template  concept C = requires { [a] = s; };
  | ^~~
0x1cfcba9 internal_error(char const*, ...)
???:0
0x7779e3 pp_cxx_parameter_mapping(cxx_pretty_printer*, tree_node*)
???:0
0x7e2a68 maybe_print_single_constraint_context(diagnostic_context*, tree_node*)
???:0
0x1cfb736 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
???:0
0x1cfc13d inform(unsigned int, char const*, ...)
???:0
0x73f30f diagnose_constraints(unsigned int, tree_node*, tree_node*)
???:0
0x98aba3 finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
???:0
0x8e14fd c_parse_file()
???:0
0xa60102 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/99923] New: Rejects valid if statement with default argument concept

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

Bug ID: 99923
   Summary: Rejects valid if statement with default argument
concept
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/zPPMEaa33

template   concept C = true;
void foo() { if (C<>) return; }

gcc rejects this valid grammar with:

: In function 'void foo()':
:2:18: error: expected 'auto' or 'decltype(auto)' after 'C<>'
2 | void foo() { if (C<>) return; }
  |  ^~~

[Bug c++/99925] New: Missing 'inconsistent deduction for ‘auto’' error when using type-constraint placeholder

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

Bug ID: 99925
   Summary: Missing 'inconsistent deduction for ‘auto’' error when
using type-constraint placeholder
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Maybe dup of PR 79009.

https://godbolt.org/z/sGacxEj31

template  concept C = true;

C auto i = 0, j = 0.5, k = "";

[Bug c++/99958] New: The seems to contain the entire and in C++20 mode

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

Bug ID: 99958
   Summary: The  seems to contain the entire 
and  in C++20 mode
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

I found that include  will automatically include the entire 
in C++17 mode, and both the  and  will be automatically
included in C++20 mode:

https://godbolt.org/z/G5hrsaPKs

#include 

int main() {
  std::string s{"hell"};
  s.push_back('o');
  std::vector v{1, 2};
  v.push_back(3);
}

[Bug c++/99967] New: gcc accepts declaration type contains unexpanded parameter pack

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

Bug ID: 99967
   Summary: gcc accepts declaration type contains unexpanded
parameter pack
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/cdqq3ocTG

template  concept C = true;

template  void f() { C auto x = 0; };

int main() { f(); }

gcc accepts it.

[Bug c++/99970] New: gcc accepts invalid comparison between pointer and integer in requires-clause

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

Bug ID: 99970
   Summary: gcc accepts invalid comparison between pointer and
integer in requires-clause
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/qs44TqzKe

template 
void f() requires requires { x == "hello world"; } {};
int main() { f(); }

gcc accepts this.

[Bug c++/99970] gcc accepts invalid comparison between pointer and integer in requires-clause

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

--- Comment #1 from 康桓瑋  ---
The requires-expression is a red herring, so it can be simplified to:

template 
void f() { x == nullptr; };

int main() { 
  f(); 
}

Is this ill-formed?

[Bug c++/99976] New: gcc accepts requires-clause contains unexpanded parameter pack

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

Bug ID: 99976
   Summary: gcc accepts requires-clause contains unexpanded
parameter pack
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/ax7MKM483

template  concept C = requires (Ts) { true; };
static_assert(C);

gcc accepts it.

[Bug c++/100006] New: ICE: in dependent_type_p, at cp/pt.c:26745

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

Bug ID: 16
   Summary: ICE: in dependent_type_p, at cp/pt.c:26745
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Congratulations on hitting the 10,000 reports mark!

https://godbolt.org/z/dhPqd4595

template 
auto f(Ts...) {
  [] { enum class e : Ts {}; };
}

int main() {
  f(0, true);
}

:3:19: internal compiler error: in dependent_type_p, at cp/pt.c:26745
3 |   [] { enum class e : Ts {}; };
  |   ^
0x1d00959 internal_error(char const*, ...)
???:0
0x6bb099 fancy_abort(char const*, int, char const*)
???:0
0x8fa338 dependent_type_p(tree_node*)
???:0
0x78b617 start_enum(tree_node*, tree_node*, tree_node*, tree_node*, bool,
bool*)
???:0
0x92ae1d lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x91766d tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x917717 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x94abba tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91d54f instantiate_decl(tree_node*, bool, bool)
???:0
0x7c7a3e maybe_instantiate_decl(tree_node*)
???:0
0x7c91a0 mark_used(tree_node*, int)
???:0
0x6de907 build_new_function_call(tree_node*, vec**, int)
???:0
0x981c3c finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e224d c_parse_file()
???:0
0xa612e2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/100006] ICE: in dependent_type_p, at cp/pt.c:26745

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

--- Comment #1 from 康桓瑋  ---
(In reply to 康桓瑋 from comment #0)
> Congratulations on hitting the 10,000 reports mark!
> 
> https://godbolt.org/z/dhPqd4595
> 
> template 
> auto f(Ts...) {
>   [] { enum class e : Ts {}; };
> }
> 
> int main() {
>   f(0, true);
> }
> 
> :3:19: internal compiler error: in dependent_type_p, at cp/pt.c:26745
> 3 |   [] { enum class e : Ts {}; };
>   |   ^
> 0x1d00959 internal_error(char const*, ...)
>   ???:0
> 0x6bb099 fancy_abort(char const*, int, char const*)
>   ???:0
> 0x8fa338 dependent_type_p(tree_node*)
>   ???:0
> 0x78b617 start_enum(tree_node*, tree_node*, tree_node*, tree_node*, bool,
> bool*)
>   ???:0
> 0x92ae1d lookup_template_class(tree_node*, tree_node*, tree_node*,
> tree_node*, int, int)
>   ???:0
> 0x91766d tsubst(tree_node*, tree_node*, int, tree_node*)
>   ???:0
> 0x917717 tsubst(tree_node*, tree_node*, int, tree_node*)
>   ???:0
> 0x94abba tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
>   ???:0
> 0x91d54f instantiate_decl(tree_node*, bool, bool)
>   ???:0
> 0x7c7a3e maybe_instantiate_decl(tree_node*)
>   ???:0
> 0x7c91a0 mark_used(tree_node*, int)
>   ???:0
> 0x6de907 build_new_function_call(tree_node*, vec vl_embed>**, int)
>   ???:0
> 0x981c3c finish_call_expr(tree_node*, vec**,
> bool, bool, int)
>   ???:0
> 0x8e224d c_parse_file()
>   ???:0
> 0xa612e2 c_common_parse_file()
>   ???:0
> Please submit a full bug report,
> with preprocessed source if appropriate.

100,000

[Bug c++/100006] [8/9/10/11 Regression] ICE: in dependent_type_p, at cp/pt.c:26745

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

--- Comment #3 from 康桓瑋  ---
https://godbolt.org/z/o6h8GP6ae

Maybe same form:

template 
auto f() {
  [] { struct S : Ts {}; };
}

int main() {
  f<>();
}

:3:15: internal compiler error: in dependent_type_p, at cp/pt.c:26745
3 |   [] { struct S : Ts {}; };
  |   ^
0x1d00959 internal_error(char const*, ...)
???:0
0x6bb099 fancy_abort(char const*, int, char const*)
???:0
0x8fa338 dependent_type_p(tree_node*)
???:0
0x7a9464 xref_basetypes(tree_node*, tree_node*)
???:0
0x95aa80 instantiate_class_template(tree_node*)
???:0
0x94abba tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91d54f instantiate_decl(tree_node*, bool, bool)
???:0
0x7c7a3e maybe_instantiate_decl(tree_node*)
???:0
0x7c91a0 mark_used(tree_node*, int)
???:0
0x6de907 build_new_function_call(tree_node*, vec**, int)
???:0
0x981c3c finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e224d c_parse_file()
???:0
0xa612e2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/100007] New: Parameter packs not expanded with bit field

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

Bug ID: 17
   Summary: Parameter packs not expanded with bit field
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/ccb69heP9

template 
auto f() {
  ([] { struct U { int x : Ns; }; }, ...);
  ([] { union  U { int x : Ns; }; }, ...);
}

gcc rejects it.

[Bug c++/100019] New: ICE Segmentation fault with try-catch block in lambda

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

Bug ID: 100019
   Summary: ICE Segmentation fault with try-catch block in lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/WajPza5fM

void f(auto... args) {
  [] {
try {} catch (decltype(args)) {}
  };
}

int main() {
  f(0);
}

:3:19: internal compiler error: Segmentation fault
3 | try {} catch (decltype(args)) {}
  |   ^~
0x1d00a79 internal_error(char const*, ...)
???:0
0x98c0ff finish_decltype_type(tree_node*, bool, int)
???:0
0x9170e3 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x9177e7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x94acb2 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91d61f instantiate_decl(tree_node*, bool, bool)
???:0
0x95f4eb instantiate_pending_templates(int)
???:0
0x7ccff9 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/100022] New: Parameter packs not expanded with alignas specifier

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

Bug ID: 100022
   Summary: Parameter packs not expanded with alignas specifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/49KvrsM9W

template 
void g() {
  ([] { struct alignas(Ns) S {}; }, ...);
}

gcc rejects it.

[Bug c++/100022] Parameter packs not expanded with alignas specifier

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

--- Comment #1 from 康桓瑋  ---
I think this is a dup of PR 16, correct me if i am wrong.

[Bug c++/100030] New: ICE: in dependent_type_p, at cp/pt.c:26757

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

Bug ID: 100030
   Summary: ICE: in dependent_type_p, at cp/pt.c:26757
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/G3a6Wq5e3

template 
auto f(Ts...) {
  [] { struct alignas(Ts) S {}; };
}

int main() {
  f(0);
}

:3:23: internal compiler error: in dependent_type_p, at cp/pt.c:26757
3 |   [] { struct alignas(Ts) S {}; };
  |   ^~
0x1d00ea9 internal_error(char const*, ...)
???:0
0x6bb009 fancy_abort(char const*, int, char const*)
???:0
0x8fa4d8 dependent_type_p(tree_node*)
???:0
0x9c561f cxx_sizeof_or_alignof_type(unsigned int, tree_node*, tree_code, bool,
bool)
???:0
0x9168ca tsubst_tree_list(tree_node*, tree_node*, int, tree_node*)
???:0
0x95acdc instantiate_class_template(tree_node*)
???:0
0x94ad92 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91d71f instantiate_decl(tree_node*, bool, bool)
???:0
0x7c7a1e maybe_instantiate_decl(tree_node*)
???:0
0x7c9180 mark_used(tree_node*, int)
???:0
0x6de877 build_new_function_call(tree_node*, vec**, int)
???:0
0x981e5c finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e223d c_parse_file()
???:0
0xa614e2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/100030] ICE: in dependent_type_p, at cp/pt.c:26757

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

--- Comment #1 from 康桓瑋  ---
Related to RP 16.

[Bug c++/100031] New: ICE: in dependent_type_p, at cp/pt.c:26757

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

Bug ID: 100031
   Summary: ICE: in dependent_type_p, at cp/pt.c:26757
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Related to PR 16, PR 100030.

https://godbolt.org/z/TxGMsEv6W

template 
auto f(Ts...) {
  []() requires (sizeof(Ts) == 0) {};
}

int main() {
  f(0);
}

:3:18: internal compiler error: in dependent_type_p, at cp/pt.c:26757
3 |   []() requires (sizeof(Ts) == 0) {};
  |  ^~
0x1d00ea9 internal_error(char const*, ...)
???:0
0x6bb009 fancy_abort(char const*, int, char const*)
???:0
0x8fa4d8 dependent_type_p(tree_node*)
???:0
0x9c561f cxx_sizeof_or_alignof_type(unsigned int, tree_node*, tree_code, bool,
bool)
???:0
0x73fdba constraints_satisfied_p(tree_node*, tree_node*)
???:0
0x804780 maybe_add_lambda_conv_op(tree_node*)
???:0
0x94addd tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91d71f instantiate_decl(tree_node*, bool, bool)
???:0
0x7c7a1e maybe_instantiate_decl(tree_node*)
???:0
0x7c9180 mark_used(tree_node*, int)
???:0
0x6de877 build_new_function_call(tree_node*, vec**, int)
???:0
0x981e5c finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0x8e223d c_parse_file()
???:0
0xa614e2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

[Bug c++/100035] New: Parameter packs not expanded with local variable in lambda

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

Bug ID: 100035
   Summary: Parameter packs not expanded with local variable in
lambda
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/ss9bjYvc1

template 
auto f(Ts...) {
  ([] { Ts x = 0; }, ...);
}

gcc rejects with:

: In function 'auto f(Ts ...)':
:3:4: error: operand of fold expression has no unexpanded parameter
packs
3 |   ([] { Ts x = 0; }, ...);
  |^~~~

[Bug libstdc++/100044] New: ranges::subrange CTAD for __iterator_sentinel_pair not work

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

Bug ID: 100044
   Summary: ranges::subrange CTAD for __iterator_sentinel_pair not
work
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

libstdc++ defines the CATD of __iterator_sentinel_pair for the subranges in
ranges_util.h#L355:

355  template<__detail::__iterator_sentinel_pair _Pr>
356subrange(_Pr)
357  -> subrange, tuple_element_t<1, _Pr>>;
358
359  template<__detail::__iterator_sentinel_pair _Pr>
360subrange(_Pr, __detail::__make_unsigned_like_t>>)
362  -> subrange, tuple_element_t<1, _Pr>,
363   subrange_kind::sized>;

It should be for the convenience to create a subrange directly from the
iterator and sentinel pair:

#include 
#include 

int main() {
  std::vector v1{1, 2, 3};
  std::pair p{v1.begin(), v1.end()};
  std::ranges::subrange sb{p};
}

But this seems to not work, since subrange(_Rng&& __r) will constraint the _Rng
 at the beginning, which will cause us to be blocked early:

: In function 'int main()':
:7:29: error: no matching function for call to
'std::ranges::subrange<__gnu_cxx::__normal_iterator > >, __gnu_cxx::__normal_iterator > >,
std::ranges::subrange_kind::sized>::subrange()'
7 |   std::ranges::subrange sb{p};

Should we consider it a library bug?

[Bug libstdc++/100044] ranges::subrange CTAD for __iterator_sentinel_pair not work

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

--- Comment #1 from 康桓瑋  ---
The problem seems to be forgetting to delete this CATD in commit
77f5310f0205714538668b88fbf1de44f1f435be.

[Bug libstdc++/100044] ranges::subrange CTAD for __iterator_sentinel_pair not work

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

--- Comment #3 from 康桓瑋  ---
Never knew the existence of this to-do list, thank you for letting me know.

[Bug c++/100084] using enum lookup isn't type-only

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

康桓瑋  changed:

   What|Removed |Added

 CC||hewillk at gmail dot com

--- Comment #3 from 康桓瑋  ---
Here is a weird case that I think should be accepted:

enum e { e };
using enum e;

gcc rejects with:

:2:12: error: 'e' is not a type
2 | using enum e;
  |^

[Bug c++/100104] New: std::transform is 1.5 times faster than std::copy with -O3

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

Bug ID: 100104
   Summary: std::transform is 1.5 times faster than std::copy with
-O3
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

Consider:

std::vector v1(100, 0);

// copy using copy
std::vector v2;
std::copy(v1.begin(), v1.end(), std::back_inserter(v2));

// copy using transform
std::vector v2;
std::transform(v1.begin(), v1.end(), std::back_inserter(v2), [](auto x) {
return x; });

Those two will generate similar assembly code under -O2, but is very different
under -O3/-Ofast, and transform will be 1.5 times faster than the copy. I don’t
know if this is a bug since these two represent the same thing, and correct me
if I am wrong.

quick-bench with -O2:
https://quick-bench.com/q/uKT8QEmPkS1wr153s3P-DRt90eY
quick-bench with -O3:
https://quick-bench.com/q/syuBCQYVtCoVwT2MRtLT25P-MQI
goldbot: 
https://godbolt.org/z/7ee77cs8W

[Bug middle-end/100104] std::transform is 1.5 times faster than std::copy with -O3

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

--- Comment #2 from 康桓瑋  ---
Build "copy" with -O2 on x86-64 (https://godbolt.org/z/Gja6xrq9G):

.LC0:
.string "vector::_M_realloc_insert"
copy(std::vector > const&):
pushr15
pxorxmm0, xmm0
pushr14
pushr13
pushr12
mov r12, rdi
pushrbp
pushrbx
sub rsp, 40
mov r13, QWORD PTR [rsi+8]
mov rbx, QWORD PTR [rsi]
movups  XMMWORD PTR [rdi], xmm0
mov QWORD PTR [rdi+16], 0
cmp rbx, r13
je  .L1
xor r8d, r8d
xor ecx, ecx
jmp .L13
.L31:
mov DWORD PTR [rcx], ebp
add rbx, 8
add rcx, 4
mov QWORD PTR [r12+8], rcx
cmp r13, rbx
je  .L1
.L13:
cvttsd2si   ebp, QWORD PTR [rbx]
cmp rcx, r8
jne .L31
movabs  rax, 2305843009213693951
mov r15, QWORD PTR [r12]
sub rcx, r15
mov rdx, rcx
mov r14, rcx
sar rdx, 2
cmp rdx, rax
je  .L32
testrdx, rdx
mov eax, 1
cmovne  rax, rdx
add rax, rdx
jc  .L7
testrax, rax
jne .L33
xor r8d, r8d
xor edi, edi
.L9:
lea rcx, [rdi+4+r14]
movqxmm0, rdi
mov DWORD PTR [rdi+r14], ebp
movqxmm1, rcx
punpcklqdq  xmm0, xmm1
testr14, r14
jg  .L34
testr15, r15
jne .L35
.L12:
add rbx, 8
mov QWORD PTR [r12+16], r8
movups  XMMWORD PTR [r12], xmm0
cmp r13, rbx
jne .L13
.L1:
add rsp, 40
mov rax, r12
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
ret
.L34:
mov rsi, r15
mov rdx, r14
mov QWORD PTR [rsp+8], r8
mov QWORD PTR [rsp], rcx
movaps  XMMWORD PTR [rsp+16], xmm0
callmemmove
mov rsi, QWORD PTR [r12+16]
mov rcx, QWORD PTR [rsp]
mov r8, QWORD PTR [rsp+8]
movdqa  xmm0, XMMWORD PTR [rsp+16]
sub rsi, r15
.L11:
mov rdi, r15
mov QWORD PTR [rsp+8], r8
mov QWORD PTR [rsp], rcx
movaps  XMMWORD PTR [rsp+16], xmm0
calloperator delete(void*, unsigned long)
movdqa  xmm0, XMMWORD PTR [rsp+16]
mov r8, QWORD PTR [rsp+8]
mov rcx, QWORD PTR [rsp]
jmp .L12
.L35:
mov rsi, QWORD PTR [r12+16]
sub rsi, r15
jmp .L11
.L33:
movabs  rdx, 2305843009213693951
cmp rax, rdx
cmova   rax, rdx
sal rax, 2
mov QWORD PTR [rsp], rax
mov rdi, rax
.L8:
calloperator new(unsigned long)
mov r8, QWORD PTR [rsp]
mov rdi, rax
add r8, rax
jmp .L9
.L7:
movabs  rax, 9223372036854775804
mov QWORD PTR [rsp], rax
mov rdi, rax
jmp .L8
.L32:
mov edi, OFFSET FLAT:.LC0
callstd::__throw_length_error(char const*)
mov rbp, rax
jmp .L15
copy(std::vector > const&) [clone .cold]:


===


with -O3:

.LC0:
.string "vector::_M_realloc_insert"
copy(std::vector > const&):
pushr15
pxorxmm0, xmm0
pushr14
pushr13
pushr12
mov r12, rdi
pushrbp
pushrbx
sub rsp, 40
mov r13, QWORD PTR [rsi+8]
mov rbx, QWORD PTR [rsi]
movups  XMMWORD PTR [rdi], xmm0
mov QWORD PTR [rdi+16], 0
cmp rbx, r13
je  .L1
xor r8d, r8d
xor ecx, ecx
jmp .L13
.L31:
mov DWORD PTR [rcx], ebp
add rbx, 8
add rcx, 4
mov QWORD PTR [r12+8], rcx
cmp r13, rbx
je  .L1
.L13:
cvttsd2si   ebp, QWORD PTR [rbx]
cmp rcx, r8
jne .L31
movabs  rax, 2305843009213693951
mov r15, QWORD PTR [r12]
sub rcx, r15
mov rdx, rcx
mov r14, rcx
sar rdx, 2
cmp rdx, rax
je  .L32
testrdx, rdx
mov eax, 1
cmovne  rax, rdx
add rax, rdx
jc  .L7
testrax, rax
jne .L33
xor r8d, r8d
xor edi, edi
.L9:
lea rcx, [rdi+4+r14]
movqxmm0, rdi
mov DWORD PTR [rdi+r14], ebp
movqxmm1, rcx
punpcklqdq  xmm0, xmm1
testr14, r14
 

[Bug middle-end/100104] std::transform is 1.5 times faster than std::copy with -O3

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

--- Comment #3 from 康桓瑋  ---
Build "copy" with -O2 on x86-64 (https://godbolt.org/z/Gja6xrq9G):

.LC0:
.string "vector::_M_realloc_insert"
copy(std::vector > const&):
pushr15
pxorxmm0, xmm0
pushr14
pushr13
pushr12
mov r12, rdi
pushrbp
pushrbx
sub rsp, 40
mov r13, QWORD PTR [rsi+8]
mov rbx, QWORD PTR [rsi]
movups  XMMWORD PTR [rdi], xmm0
mov QWORD PTR [rdi+16], 0
cmp rbx, r13
je  .L1
xor r8d, r8d
xor ecx, ecx
jmp .L13
.L31:
mov DWORD PTR [rcx], ebp
add rbx, 8
add rcx, 4
mov QWORD PTR [r12+8], rcx
cmp r13, rbx
je  .L1
.L13:
cvttsd2si   ebp, QWORD PTR [rbx]
cmp rcx, r8
jne .L31
movabs  rax, 2305843009213693951
mov r15, QWORD PTR [r12]
sub rcx, r15
mov rdx, rcx
mov r14, rcx
sar rdx, 2
cmp rdx, rax
je  .L32
testrdx, rdx
mov eax, 1
cmovne  rax, rdx
add rax, rdx
jc  .L7
testrax, rax
jne .L33
xor r8d, r8d
xor edi, edi
.L9:
lea rcx, [rdi+4+r14]
movqxmm0, rdi
mov DWORD PTR [rdi+r14], ebp
movqxmm1, rcx
punpcklqdq  xmm0, xmm1
testr14, r14
jg  .L34
testr15, r15
jne .L35
.L12:
add rbx, 8
mov QWORD PTR [r12+16], r8
movups  XMMWORD PTR [r12], xmm0
cmp r13, rbx
jne .L13
.L1:
add rsp, 40
mov rax, r12
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
ret
.L34:
mov rsi, r15
mov rdx, r14
mov QWORD PTR [rsp+8], r8
mov QWORD PTR [rsp], rcx
movaps  XMMWORD PTR [rsp+16], xmm0
callmemmove
mov rsi, QWORD PTR [r12+16]
mov rcx, QWORD PTR [rsp]
mov r8, QWORD PTR [rsp+8]
movdqa  xmm0, XMMWORD PTR [rsp+16]
sub rsi, r15
.L11:
mov rdi, r15
mov QWORD PTR [rsp+8], r8
mov QWORD PTR [rsp], rcx
movaps  XMMWORD PTR [rsp+16], xmm0
calloperator delete(void*, unsigned long)
movdqa  xmm0, XMMWORD PTR [rsp+16]
mov r8, QWORD PTR [rsp+8]
mov rcx, QWORD PTR [rsp]
jmp .L12
.L35:
mov rsi, QWORD PTR [r12+16]
sub rsi, r15
jmp .L11
.L33:
movabs  rdx, 2305843009213693951
cmp rax, rdx
cmova   rax, rdx
sal rax, 2
mov QWORD PTR [rsp], rax
mov rdi, rax
.L8:
calloperator new(unsigned long)
mov r8, QWORD PTR [rsp]
mov rdi, rax
add r8, rax
jmp .L9
.L7:
movabs  rax, 9223372036854775804
mov QWORD PTR [rsp], rax
mov rdi, rax
jmp .L8
.L32:
mov edi, OFFSET FLAT:.LC0
callstd::__throw_length_error(char const*)
mov rbp, rax
jmp .L15
copy(std::vector > const&) [clone .cold]:


===


with -O3:

.LC0:
.string "vector::_M_realloc_insert"
copy(std::vector > const&):
pushr15
pxorxmm0, xmm0
pushr14
pushr13
pushr12
mov r12, rdi
pushrbp
pushrbx
sub rsp, 40
mov r13, QWORD PTR [rsi+8]
mov rbx, QWORD PTR [rsi]
movups  XMMWORD PTR [rdi], xmm0
mov QWORD PTR [rdi+16], 0
cmp rbx, r13
je  .L1
xor r8d, r8d
xor ecx, ecx
jmp .L13
.L31:
mov DWORD PTR [rcx], ebp
add rbx, 8
add rcx, 4
mov QWORD PTR [r12+8], rcx
cmp r13, rbx
je  .L1
.L13:
cvttsd2si   ebp, QWORD PTR [rbx]
cmp rcx, r8
jne .L31
movabs  rax, 2305843009213693951
mov r15, QWORD PTR [r12]
sub rcx, r15
mov rdx, rcx
mov r14, rcx
sar rdx, 2
cmp rdx, rax
je  .L32
testrdx, rdx
mov eax, 1
cmovne  rax, rdx
add rax, rdx
jc  .L7
testrax, rax
jne .L33
xor r8d, r8d
xor edi, edi
.L9:
lea rcx, [rdi+4+r14]
movqxmm0, rdi
mov DWORD PTR [rdi+r14], ebp
movqxmm1, rcx
punpcklqdq  xmm0, xmm1
testr14, r14
 

[Bug middle-end/100104] std::transform is 1.5 times faster than std::copy with -O3

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

--- Comment #4 from 康桓瑋  ---
And Build "copy" with -O2 on ARM64 is identical with -O3
(https://godbolt.org/z/5hjKGbrTd):


.LC0:
.string "vector::_M_realloc_insert"
transform(std::vector > const&):
stp x29, x30, [sp, -64]!
mov x29, sp
stp x19, x20, [sp, 16]
mov x19, x8
ldp x20, x0, [x0]
stp xzr, xzr, [x8]
str xzr, [x8, 16]
sub x0, x0, x20
cmp x0, 0
ble .L19
mov x1, 0
str x21, [sp, 32]
asr x21, x0, 3
mov x0, 0
b   .L23
.L35:
str w2, [x0], 4
add x20, x20, 8
subsx21, x21, #1
str x0, [x19, 8]
beq .L34
.L36:
ldp x0, x1, [x19, 8]
.L23:
ldr d0, [x20]
fcvtzs  w2, d0
str w2, [sp, 60]
cmp x1, x0
bne .L35
add x2, sp, 60
mov x0, x19
bl  void std::vector
>::_M_realloc_insert(__gnu_cxx::__normal_iterator > >, int&&)
add x20, x20, 8
subsx21, x21, #1
bne .L36
.L34:
ldr x21, [sp, 32]
.L19:
mov x0, x19
ldp x19, x20, [sp, 16]
ldp x29, x30, [sp], 64
ret
ldr x2, [x19]
ldr x1, [x19, 16]
mov x19, x0
sub x1, x1, x2
cbz x2, .L25
mov x0, x2
bl  operator delete(void*, unsigned long)
.L25:
mov x0, x19
bl  _Unwind_Resume
DW.ref.__gxx_personality_v0:
.xword  __gxx_personality_v0


===



However, "transform" has been further optimized under -O3
(https://godbolt.org/z/5hjKGbrTd):

.LC0:
.string "vector::_M_realloc_insert"
transform(std::vector > const&):
stp x29, x30, [sp, -96]!
mov x29, sp
stp x19, x20, [sp, 16]
stp x21, x22, [sp, 32]
mov x21, x8
ldp x20, x22, [x0]
stp xzr, xzr, [x8]
str xzr, [x8, 16]
cmp x22, x20
beq .L1
mov x19, 0
stp x23, x24, [sp, 48]
stp x25, x26, [sp, 64]
mov x25, 2305843009213693951
stp x27, x28, [sp, 80]
mov x28, 0
b   .L13
.L32:
str w27, [x19], 4
add x20, x20, 8
str x19, [x21, 8]
cmp x22, x20
beq .L31
.L13:
ldr d0, [x20]
fcvtzs  w27, d0
cmp x19, x28
bne .L32
ldr x24, [x21]
sub x23, x19, x24
asr x1, x23, 2
cmp x1, x25
beq .L33
cmp x1, 0
csinc   x0, x1, xzr, ne
addsx0, x0, x1
bcs .L7
cbnzx0, .L34
mov x28, 0
mov x26, 0
.L9:
add x19, x23, 4
str w27, [x26, x23]
add x19, x26, x19
cmp x23, 0
bgt .L35
cbnzx24, .L36
.L12:
add x20, x20, 8
stp x26, x19, [x21]
str x28, [x21, 16]
cmp x22, x20
bne .L13
.L31:
ldp x23, x24, [sp, 48]
ldp x25, x26, [sp, 64]
ldp x27, x28, [sp, 80]
.L1:
mov x0, x21
ldp x19, x20, [sp, 16]
ldp x21, x22, [sp, 32]
ldp x29, x30, [sp], 96
ret
.L35:
mov x1, x24
mov x2, x23
mov x0, x26
bl  memmove
ldr x1, [x21, 16]
sub x1, x1, x24
.L11:
mov x0, x24
bl  operator delete(void*, unsigned long)
b   .L12
.L36:
ldr x1, [x21, 16]
sub x1, x1, x24
b   .L11
.L34:
cmp x0, x25
cselx0, x0, x25, ls
lsl x28, x0, 2
.L8:
mov x0, x28
bl  operator new(unsigned long)
mov x26, x0
add x28, x0, x28
b   .L9
.L7:
mov x28, 9223372036854775804
b   .L8
.L33:
adrpx0, .LC0
add x0, x0, :lo12:.LC0
bl  std::__throw_length_error(char const*)
ldr x2, [x21]
mov x19, x0
ldr x1, [x21, 16]
sub x1, x1, x2
cbz x2, .L16
mov x0, x2
bl  operator delete(void*, unsigned long)
.L16:
mov x0, x19
bl  _Unwind_Resume
DW.ref.__gxx_personality_v0:
.xword  __gxx_personality_v0

[Bug c++/100109] New: ICE: unexpected expression 'E' of kind template_parm_index

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

Bug ID: 100109
   Summary: ICE: unexpected expression 'E' of kind
template_parm_index
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/Go1W7YrYs

template 
void f() {
  [] { enum e { e = E }; };
}

template void f<>();

:3:13: internal compiler error: unexpected expression 'E' of kind
template_parm_index
3 |   [] { enum e { e = E }; };
  | ^
0x1d02849 internal_error(char const*, ...)
???:0
0x7a74bd build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int)
???:0
0x92c3c8 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x9182fd tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x9183a7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x94b882 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x91e1df instantiate_decl(tree_node*, bool, bool)
???:0
0x9600bb instantiate_pending_templates(int)
???:0
0x7cd579 c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.

  1   2   3   4   5   6   >