[Bug c++/115378] New: [ice-on-valid] code using friend injection is crashing gcc since 14

2024-06-06 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115378

Bug ID: 115378
   Summary: [ice-on-valid] code using friend injection is crashing
gcc since 14
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

the following valid code crashes gcc-14 and gcc-trunk. clang accepts it, as
does gcc-13. see https://godbolt.org/z/s9frvq3Pv


#include 
#include 
#include 
#include 
#include 
#include 
#include 

#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wnon-template-friend"
#endif

namespace std::execution {
  template 
  concept __has_query =
requires (const Env& __env, Args&&... __args) {
  __env.query(Query(), std::forward(__args)...);
};

  // specialization for key/value pairs
  template 
  struct prop {
[[no_unique_address]] Query __query;
[[no_unique_address]] Value __value;

[[nodiscard]] constexpr const Value & query(Query) const noexcept {
  return __value;
}
  };

  template 
  prop(Query, Value) -> prop>;

  template 
  struct __ref;

  template 
  struct __ref {
Env& __env;

constexpr __ref(reference_wrapper __r) noexcept : __env(__r) {}

template 
  requires __has_query
constexpr decltype(auto) query(Query __q, Args&&... args) const
  noexcept(noexcept(__env.query(__q, std::forward(args)...))) {
  return __env.query(__q, std::forward(args)...);
}
  };

  template
  struct __reader {
friend auto __counted_flag(__reader);
  };

  template
  struct __writer {
friend auto __counted_flag(__reader) {}
static constexpr size_t __n = N;
  };

  template
  consteval auto __counter_impl() {
constexpr bool __counted_past_value = requires(__reader __r)
{
  __counted_flag(__r);
};

if constexpr (__counted_past_value) {
  return __counter_impl();
} else {
  return __writer().__n;
}
  }

  template()>
  constexpr auto __counter = Val;

  template struct __list;

  template 
  struct __ignore {
constexpr __ignore(auto&&) {}
auto query(auto) const = delete;
  };

  template 
  using __wrap = conditional_t, __ref, Env>;

  template 
  using _as_base_ = conditional_t, __ignore>;

  template >>
  using _as_base = _as_base_;

  // utility for joining multiple environments
  template 
  struct env : _as_base, Envs>... {
template 
constexpr decltype(auto) __get_1st() const noexcept {
  constexpr bool __flags[] = {__has_query...};
  constexpr size_t __idx = ranges::find(__flags, true) - __flags;
  auto __tup = tie(static_cast&>(*this)...);
  return get<__idx>(__tup);
}

template 
  requires (__has_query ||...)
constexpr decltype(auto) query(Query __q, Args&&... args) const
  noexcept(noexcept(__get_1st().query(__q,
std::forward(args)...))) {
  return __get_1st().query(__q,
std::forward(args)...);
}
  };

  template 
  env(Envs...) -> env...>;
} // std::execution

// Test code:
template 
struct get_value_t {
  auto operator()(const auto& env) const noexcept -> decltype(env.query(*this))
{
static_assert(noexcept(env.query(*this)));
return env.query(*this);
  }
};

template 
inline constexpr get_value_t get_value{};

int main() {
  using namespace std::execution;

  // can create an environment out of a query and a value
  auto env1 = prop(get_value<0>, 42);
  auto val = get_value<0>(env1);
  assert(val == 42);

  // can store a value by reference:
  int i = 42;
  auto env2 = prop(get_value<0>, std::ref(i));
  int& j = get_value<0>(env2);
  ++j;
  assert(i == 43);

  // Can create an env from several envs with duplicates.
  // Queries are resolved by asking the nested envs first to last.
  auto env3 = env(prop(get_value<0>, 42),
  prop(get_value<1>, 43),
  prop(get_value<1>, 44),
  prop(get_value<0>, 45),
  prop(get_value<0>, 46));
  assert(get_value<0>(env3) == 42);
  assert(get_value<1>(env3) == 43);

  // nested envs can be held by reference also:
  auto env4 = env(prop(get_value<1>, 42), std::cref(env2));
  assert(get_value<0>(env4) == 43);
  assert(get_value<1>(env4) == 42);
}

[Bug c++/115114] New: aggregate initialization with parens fails when there is a base class

2024-05-15 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115114

Bug ID: 115114
   Summary: aggregate initialization with parens fails when there
is a base class
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

I believe the following is valid C++20:

  struct get_answer {};

  template 
  struct with : Query {
Value value;
  };

  int main() {
with w1{get_answer(), 42}; // works

with w2(get_answer(), 42); // fails
  }

clang and msvc accept this code. gcc-trunk rejects it. See
https://godbolt.org/z/KvGjn47f9.

If I change the definition of the `with` class template to the following, the
code compiles:

  template 
  struct with {
Query query;
Value value;
  };

[Bug c++/114138] New: [c++2b] ICE on valid code using `auto(expr)` DECAY-COPY

2024-02-27 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114138

Bug ID: 114138
   Summary: [c++2b] ICE on valid code using `auto(expr)`
DECAY-COPY
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Compile the following with -c++=2b:


```
namespace std {
  template 
  T&& declval() noexcept requires true;

  template 
  void declval() noexcept;

  namespace detail {
struct none_such;
template 
using none_such_t = none_such;

template 
  extern const none_such_t _getter_for;

template 
using _decay_t = decltype(auto(declval()));

static_assert(__is_same_as(_decay_t, void));
  }

  template 
using _result_of_t = decltype(Fn(declval()...));

  template 
using tuple_element_t =
_result_of_t>, char(*)[I+1],
Tuple>;

  template 
  struct pair {
First first;
Second second;
  };

  template 
inline constexpr bool _is_pair = false;

  template 
inline constexpr bool _is_pair> = true;

  template 
concept Pair = _is_pair()))>;

  template 
requires (I <= 1)
  decltype(auto) get(P&& p) noexcept {
if constexpr (I == 0) {
  return (static_cast(p).first);
} else {
  return (static_cast(p).second);
}
  }

  namespace detail {
inline constexpr auto _pair_getter =
  [](char(*)[J], Pair&& p) noexcept ->
decltype(auto) {
return std::get(static_cast(p));
  };

template 
  inline constexpr auto _getter_for> = _pair_getter;
  }

}

int main() {

  static_assert(__is_same_as(int&, std::tuple_element_t<0, std::pair&>));
  static_assert(__is_same_as(float&&, std::tuple_element_t<1, std::pair&&>));
}
```


Result:

```
: In substitution of 'template using
std::tuple_element_t = std::_result_of_t<_getter_for()))>, char (*)[(I + 1)], Tuple> [with unsigned int I =
0; Tuple = std::pair&]':
:71:82:   required from here
   71 |   static_assert(__is_same_as(int&, std::tuple_element_t<0,
std::pair&>));
  |
 ^
:21:31: internal compiler error: in tsubst, at cp/pt.cc:16367
   21 | using _decay_t = decltype(auto(declval()));
  |   ^~
0x265412c internal_error(char const*, ...)
???:0
0xa548c3 fancy_abort(char const*, int, char const*)
???:0
0xc99307 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xc9f3c9 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xc9f3c9 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xc98a19 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xc80873 instantiate_template(tree_node*, tree_node*, int)
???:0
0xc9a0fc tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xc973cc lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0xcd370f finish_template_type(tree_node*, tree_node*, int)
???:0
0xc577da c_parse_file()
???:0
0xdaba19 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

See https://godbolt.org/z/r13Yff5bM

[Bug c++/111018] New: lexical interpretation of friendship rules depends on whether the friend function has a definition

2023-08-14 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111018

Bug ID: 111018
   Summary: lexical interpretation of friendship rules depends on
whether the friend function has a definition
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Starting in gcc 12, transitive friendship is extended to friend functions that
are defined lexically within the body of the friend class. E.g.:


struct S;

struct T {
  friend struct S;
private:
  template 
  static void foo(T) {}
};

struct S {
  template 
  friend auto bar(Self s) -> decltype(::T::foo(s)) { // (1)
return ::T::foo(s);
  }
};

Prior to gcc-12, the commented line would have been rejected, but now it is
accepted. Great, it brings gcc in line with clang and is arguably more
sensible.

HOWEVER, it does NOT work if the friend function is merely declared but not
defined. For instance, this is still an error:

struct S;

struct T {
  friend struct S;
private:
  template 
  static void foo(T) {}
};

struct S {
  template 
  friend auto bar(Self s) -> decltype(::T::foo(s)); // NO FN DEFINITION
};

int main() {
  S s;
  using T = decltype(bar(s)); // ERROR: T::foo is private
}


This is very confusing and inconsistent behavior.

See: https://godbolt.org/z/WT9P37Wba

[Bug c++/110681] New: bogus warning -Wreturn-type for lambda in tparam list

2023-07-15 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110681

Bug ID: 110681
   Summary: bogus warning -Wreturn-type for lambda in tparam list
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following valid C++20 code causes gcc trunk to erroneously warn about a
missing return statement.


  template 
  constexpr auto y = X;

  template 
  using C = decltype(y<>);

  using D = C;


: In substitution of 'template using C = decltype (y<
>) [with T = int]':
:27:18:   required from here
:21:22: warning: no return statement in function returning non-void
[-Wreturn-type]
   21 |   template 
  |  ^~~~
Compiler returned: 0

[Bug c++/110680] New: erroneous error "non-template type 'C' used as a template"

2023-07-15 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110680

Bug ID: 110680
   Summary: erroneous error "non-template type 'C' used as a
template"
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following valid C++20 is rejected by gcc trunk:


  template 
  struct S {
auto f() { return X; }
  };

  template 
  using C = decltype(S().f());

  using D = C;


:29:16: error: non-template type 'C' used as a template
   29 | using D = C;
  |^
Compiler returned: 1


https://godbolt.org/z/b3eY8fWTv

[Bug c++/110552] New: ICE on valid code in maybe_instantiate_noexcept

2023-07-04 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110552

Bug ID: 110552
   Summary: ICE on valid code in maybe_instantiate_noexcept
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Created attachment 55469
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55469=edit
self-contained source file

Compile the attached source with -std=c++20. Result:

/home/eniebler/hello_world.cpp: In substitution of ‘template  requires  tag_invocable constexpr
stdexec::__tag_invoke::tag_invoke_result_t stdexec::__env::get_env_t::operator()(const _EnvProvider&) const
[with _EnvProvider = stdexec::__basic_sender<:: >]’:
/home/eniebler/hello_world.cpp:2221:16:   required from here
/home/eniebler/hello_world.cpp:1465:59: internal compiler error: in
maybe_instantiate_noexcept, at cp/pt.cc:26753
 1465 |   requires(_Tag __tag, _Args&&... __args) { tag_invoke((_Tag&&)
__tag, (_Args&&) __args...); };
  |
~~^
0xace10a maybe_instantiate_noexcept(tree_node*, int)
../../gcc/cp/pt.cc:26753
0x96272f mark_used(tree_node*, int)
../../gcc/cp/decl2.cc:5720
0x864a35 build_over_call
../../gcc/cp/call.cc:10394
0x867e0b build_new_function_call(tree_node*, vec**, int)
../../gcc/cp/call.cc:5038
0xb304ff finish_call_expr(tree_node*, vec**, bool,
bool, int)
../../gcc/cp/semantics.cc:2924
0xacc4e5 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.cc:21338
0xabb964 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.cc:19888
0x8c3193 tsubst_valid_expression_requirement
../../gcc/cp/constraint.cc:2002
0x8cc3c0 tsubst_simple_requirement
../../gcc/cp/constraint.cc:2036
0x8cc3c0 tsubst_requirement
../../gcc/cp/constraint.cc:2233
0x8cc3c0 tsubst_requires_expr
../../gcc/cp/constraint.cc:2363
0x8cc8aa tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/constraint.cc:2382
0xac96c7 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.cc:21749
0xabb964 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
../../gcc/cp/pt.cc:19888
0x8cde63 satisfy_atom
../../gcc/cp/constraint.cc:3041
0x8cde63 satisfy_constraint_r
../../gcc/cp/constraint.cc:3106
0x8ce723 satisfy_normalized_constraints
../../gcc/cp/constraint.cc:3131
0x8caefd satisfy_declaration_constraints
../../gcc/cp/constraint.cc:3352
0x8caefd constraint_satisfaction_value
../../gcc/cp/constraint.cc:3373
0x8ce78f constraints_satisfied_p(tree_node*, tree_node*)
../../gcc/cp/constraint.cc:3410
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.


See https://godbolt.org/z/1511TYvch for a demo of the bug on compiler explorer.

[Bug c++/110536] New: Bogus -Wstringop-overflow warning in std::transform

2023-07-03 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110536

Bug ID: 110536
   Summary: Bogus -Wstringop-overflow warning in std::transform
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Compile the following with -O3 -std=c++17 -Wall

<
#include 
#include 

template 
std::vector
make_type_param_vector(std::initializer_list const& init_list) {
  // std::vector input{init_list}; //uncomment to remove warning
  std::vector vec(init_list.size());
  std::transform(std::cbegin(init_list), std::cend(init_list), std::begin(vec),
[](auto const& e) {
if constexpr (std::is_unsigned_v) { return
static_cast(std::abs(e)); }
return static_cast(e);
  });
  return vec;
}

template 
void validate_A() {
  auto const input_column_valid_a = make_type_param_vector({1, 0});
  auto const input_column_valid_b = make_type_param_vector({0, 0});
  auto const input_column_valid_c = make_type_param_vector({15, 16});
}

int main() {
  validate_A();
  validate_A();
  validate_A();
  validate_A();
  validate_A();
  validate_A();
  validate_A();
  validate_A();
  validate_A();
}

<:1:
In function '_OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation)
[with _IIter = const int*; _OIter = __gnu_cxx::__normal_iterator > >; _UnaryOperation =
make_type_param_vector(const
std::initializer_list&)::]',
inlined from 'std::vector make_type_param_vector(const
std::initializer_list&) [with TypeParam = unsigned char; T = int]' at
:10:17:
/opt/compiler-explorer/gcc-trunk-20230703/include/c++/14.0.0/bits/stl_algo.h:4216:19:
warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 4216 | *__result = __unary_op(*__first);
  | ~~^~


Demo:
https://godbolt.org/z/PKqfjr9cb

[Bug libstdc++/110507] New: cannot initialize immovable type in a std::tuple

2023-06-30 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110507

Bug ID: 110507
   Summary: cannot initialize immovable type in a std::tuple
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following should work since C++17, when C++ got guaranteed copy elision.


#include 

struct immovable {
  immovable() = default;
  immovable(immovable&&) = delete;
};

struct init_immovable {
  operator immovable() const { return {}; }
};

int main() {
  std::tuple m{init_immovable{}};
}


result:

In file included from :1:
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple: In
instantiation of 'constexpr std::_Head_base<_Idx, _Head,
true>::_Head_base(_UHead&&) [with _UHead = init_immovable; long unsigned int
_Idx = 0; _Head = immovable]':
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:514:38:  
required from here
:13:43:   in 'constexpr' expansion of
'm.std::tuple::tuple(init_immovable())'
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:891:54:   in
'constexpr' expansion of '((std::_Tuple_impl<0,
immovable>*)this)->std::_Tuple_impl<0,
immovable>::_Tuple_impl((* & std::forward((* &
__elements#0'
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:92:11:
error: use of deleted function 'immovable::immovable(immovable&&)'
   92 | : _M_head_impl(std::forward<_UHead>(__h)) { }
  |   ^~~
:5:3: note: declared here
5 |   immovable(immovable&&) = delete;
  |   ^


https://godbolt.org/z/nfd1zdcqs

[Bug c++/110441] New: c++17 deferred materialization of temporaries fails when calling class static with member syntax

2023-06-27 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110441

Bug ID: 110441
   Summary: c++17 deferred materialization of temporaries fails
when calling class static with member syntax
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

struct immovable {
  immovable() = default;
  immovable(immovable &&) = delete;
};

struct S {
  static immovable f() {
return {};
  }
};

immovable g() { 
  return S().f();
}

compile with -std=c++17. Result:

: In function 'immovable g()':
:14:15: error: use of deleted function
'immovable::immovable(immovable&&)'
   14 |   return S().f();
  |  ~^~
:4:3: note: declared here
4 |   immovable(immovable &&) = delete;
  |   ^


https://godbolt.org/z/Y1h9bPrf3

[Bug c++/109790] internal compiler error in write_member_name, at cp/mangle.cc:2992

2023-05-09 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109790

--- Comment #1 from Eric Niebler  ---
Possible dupe of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100632

[Bug c++/109790] New: internal compiler error in write_member_name, at cp/mangle.cc:2992

2023-05-09 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109790

Bug ID: 109790
   Summary: internal compiler error in write_member_name, at
cp/mangle.cc:2992
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Created attachment 55032
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55032=edit
the result of -freport-bug

Compile the attached test_when_all.i.cpp with:

  g++ -std=c++20 -fext-numeric-literals -Wno-non-template-friend \
test_when_all.i.cpp

Result:

In file included from
/home/eniebler/Code/stdexec/include/stdexec/execution.hpp:35,
 from
/home/eniebler/Code/stdexec/test/stdexec/algos/adaptors/test_when_all.cpp:18:
/home/eniebler/Code/stdexec/include/stdexec/__detail/__tuple.hpp: In
instantiation of ‘constexpr stdexec::__tup::__tuple_for<_Ts ...>
stdexec::__tup::__make_tuple_fn::operator()(_Ts ...) const [with _Ts =
{C_A_T_C_HT_E_S_T24()::}]’:
/home/eniebler/Code/stdexec/include/stdexec/__detail/__tuple.hpp:284:37:  
required from here
/home/eniebler/Code/stdexec/include/stdexec/__detail/__tuple.hpp:284:37:
internal compiler error: in write_member_name, at cp/mangle.cc:2992
  284 |   constexpr __tuple_for<_Ts...> operator()(_Ts... __ts) const
  | ^~~~
0x9acf33 write_member_name
../../gcc/cp/mangle.cc:2992
0x9ace8f write_member_name
../../gcc/cp/mangle.cc:2999
0x9ad8ce write_expression
../../gcc/cp/mangle.cc:3668
0x9adecc write_expression
../../gcc/cp/mangle.cc:3592
0x9b290c write_type
../../gcc/cp/mangle.cc:2489
0x9b198c write_template_args
../../gcc/cp/mangle.cc:2966
0x9b7e2f write_nested_name
../../gcc/cp/mangle.cc:1154
0x9b26de write_class_enum_type
../../gcc/cp/mangle.cc:2937
0x9b26de write_type
../../gcc/cp/mangle.cc:2362
0x9b6739 write_bare_function_type
../../gcc/cp/mangle.cc:2856
0x9b699b write_mangled_name
../../gcc/cp/mangle.cc:799
0x9b8827 mangle_decl_string
../../gcc/cp/mangle.cc:4143
0x9b8ac8 get_mangled_id
../../gcc/cp/mangle.cc:4164
0x9b8ac8 mangle_decl(tree_node*)
../../gcc/cp/mangle.cc:4202
0x15934b5 decl_assembler_name(tree_node*)
../../gcc/tree.cc:715
0x15c6d59 assign_assembler_name_if_needed(tree_node*)
../../gcc/tree.cc:830
0xd126f1 cgraph_node::analyze()
../../gcc/cgraphunit.cc:677
0xd15f7a analyze_functions
../../gcc/cgraphunit.cc:1247
0xd170ed symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.cc:2554
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/109782] New: erroneous error "'auto' parameter not permitted in this context" for generic lambda in tparam list

2023-05-08 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109782

Bug ID: 109782
   Summary: erroneous error "'auto' parameter not permitted in
this context" for generic lambda in tparam list
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

template 
struct C {};


...compiled with `-std=c++20` results in:

:1:23: error: 'auto' parameter not permitted in this context
1 | template 
  |   ^~~~
Compiler returned: 1

[Bug c++/109781] New: erroneous error "lambda-expression in template parameter type" for tparam lambda returning a lambda

2023-05-08 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781

Bug ID: 109781
   Summary: erroneous error "lambda-expression in template
parameter type" for tparam lambda returning a lambda
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

template 
struct C {};


... on trunk with `-std=c++20` results in:

: In lambda function:
:1:31: error: lambda-expression in template parameter type
1 | template 
  |   ^
Compiler returned: 1


I don't know of a reason why this code should be rejected.

[Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)

2023-05-08 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105667

Eric Niebler  changed:

   What|Removed |Added

 CC||eric.niebler at gmail dot com

--- Comment #7 from Eric Niebler  ---
Another, even shorter repro:

template (B){}>
struct C {
  using D = void;
};

template 
using E = C<>::D;

using F = E<>;

[Bug c++/109754] New: [ICE] internal compiler error: in coerce_template_parms, at cp/pt.cc:9183

2023-05-05 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109754

Bug ID: 109754
   Summary: [ICE] internal compiler error: in
coerce_template_parms, at cp/pt.cc:9183
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Created attachment 55012
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55012=edit
result of -freport-bug including preprocessed source

similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105475, but not using
coroutines

Repro: compile attached code with -std=c++20  

Result:

In file included from test.cpp:1:
stdexec/include/stdexec/__detail/__meta.hpp: In substitution of ‘template using __minvoke = stdexec::__meval<_Fn::template __f,
_Args ...> [with _Fn =
stdexec::__mexpand, const char*>(int&&,
stdexec::__tup::__coerce&&, const char*&&)
const > >; _Args = {stdexec::__msize}]’:
stdexec/include/stdexec/__detail/__meta.hpp:431:9:   required by substitution
of ‘template using __mapply =
stdexec::__minvoke, _Fn> [with _Fn =
stdexec::__msize; _List =
stdexec::__tuple, const char*>(int&&,
stdexec::__tup::__coerce&&, const char*&&)
const >]’
stdexec/include/stdexec/__detail/__tuple.hpp:491:47:   required from ‘const
std::size_t
stdexec::tuple_size_v, const char*>(int&&,
stdexec::__tup::__coerce&&, const char*&&)
const > >’
test.cpp:22:26:   required from here
stdexec/include/stdexec/__detail/__meta.hpp:233:9: internal compiler error: in
coerce_template_parms, at cp/pt.cc:9183
  233 |   using __minvoke = __meval<_Fn::template __f, _Args...>;
  | ^
0x6623b1 coerce_template_parms
../../src/gcc/cp/pt.cc:9183
0x818feb instantiate_alias_template
../../src/gcc/cp/pt.cc:21719
0x818feb tsubst(tree_node*, tree_node*, int, tree_node*)
../../src/gcc/cp/pt.cc:15607
0x81c344 tsubst_decl
../../src/gcc/cp/pt.cc:14952
0x81815a instantiate_template_1
../../src/gcc/cp/pt.cc:21643
0x81908e instantiate_template(tree_node*, tree_node*, int)
../../src/gcc/cp/pt.cc:21702
0x81908e instantiate_alias_template
../../src/gcc/cp/pt.cc:21740
0x81908e tsubst(tree_node*, tree_node*, int, tree_node*)
../../src/gcc/cp/pt.cc:15607
0x81c344 tsubst_decl
../../src/gcc/cp/pt.cc:14952
0x81815a instantiate_template_1
../../src/gcc/cp/pt.cc:21643
0x81908e instantiate_template(tree_node*, tree_node*, int)
../../src/gcc/cp/pt.cc:21702
0x81908e instantiate_alias_template
../../src/gcc/cp/pt.cc:21740
0x81908e tsubst(tree_node*, tree_node*, int, tree_node*)
../../src/gcc/cp/pt.cc:15607
0x825bad tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
../../src/gcc/cp/pt.cc:13517
0x8108fe tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.cc:20055
0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.cc:19491
0x81fe84 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.cc:18462
0x81fe84 instantiate_decl(tree_node*, bool, bool)
../../src/gcc/cp/pt.cc:26653
0x7313c1 maybe_instantiate_decl(tree_node*)
../../src/gcc/cp/decl2.cc:5627
0x7375ef maybe_instantiate_decl(tree_node*)
../../src/gcc/cp/decl2.cc:5614
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/108848] New: Accessing class static member of non-dependent expression using member syntax in dependent context is rejected

2023-02-20 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108848

Bug ID: 108848
   Summary: Accessing class static member of non-dependent
expression using member syntax in dependent context is
rejected
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Clang accepts the following, gcc thinks the expression in the line marked
"HERE" should be `tag.template smbr`.

template 
struct tag_t {
  template 
  static constexpr const Sig* smbr = nullptr; 
  int i = 0;
};

template 
inline constexpr tag_t tag {};

// This is OK
using X = decltype(tag.smbr);

template 
struct S {
  // This is incorrectly rejected by gcc
  using Y = decltype(tag.smbr);

  // This is OK
  using Z = decltype(tag_t::smbr);
};

https://godbolt.org/z/9GoPYTYa1

[Bug libstdc++/97876] stop_token header doesn't compile on clang-8 with -std=c++20

2020-11-19 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97876

--- Comment #5 from Eric Niebler  ---
> Github's poor life choices should not be our problem ;-)

I thought you'd say that. :-)

> If clang-8 doesn't ship  and doesn't work with GCC's 
> , I would interpret that as you can't test  with 
> clang-8.

Yeah, except I'm not trying to test . I'm just trying to include
, which includes  and hard-errors. In fact,
what I'm _really_ trying to do is include , which includes
, which includes , which includes
. All roads, it seems, lead to .

[Bug libstdc++/97876] stop_token header doesn't compile on clang-8 with -std=c++20

2020-11-17 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97876

--- Comment #3 from Eric Niebler  ---
It seems like GitHub actions uses the latest libstdc++ by default when testing
even with old (e.g., clang-4) toolsets. That seems busted, but regardless, this
is now breaking _all_ my Linux clang tests for anything less than clang-9,
which is unfortunate.

[Bug libstdc++/97876] New: stop_token header doesn't compile on clang-8 with -std=c++20

2020-11-17 Thread eric.niebler at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97876

Bug ID: 97876
   Summary: stop_token header doesn't compile on clang-8 with
-std=c++20
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

Compiling  header with clang-8 in C++20 mode results in this:

In file included from
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/condition_variable:50:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stop_token:404:7:
error: default member initializer for '_M_ptr' needed within definition of
enclosing class 'stop_token' outside of member functions
  _Stop_state_ref() = default;
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stop_token:478:21:
note: in evaluation of exception specification for
'std::stop_token::_Stop_state_ref::_Stop_state_ref' needed here
_Stop_state_ref _M_state;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stop_token:58:5:
note: in evaluation of exception specification for
'std::stop_token::stop_token' needed here
stop_token() noexcept = default;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stop_token:475:22:
note: default member initializer declared here
  _Stop_state_t* _M_ptr = nullptr;
 ^
1 error generated.