[Bug c++/96355] [concepts] internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928

2020-08-18 Thread rwdougla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96355

Robert Douglas  changed:

   What|Removed |Added

 CC||rwdougla at gmail dot com

--- Comment #1 from Robert Douglas  ---
I've also hit this issue in upgrading from 9.1 to 10.2

I presume it run into the same issue, but if it helps, this more closely
matches my use case:
https://godbolt.org/z/zb1bP5

[Bug c++/91073] New: if constexpr no longer works directly with Concepts

2019-07-03 Thread rwdougla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91073

Bug ID: 91073
   Summary: if constexpr no longer works directly with Concepts
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rwdougla at gmail dot com
  Target Milestone: ---

It appears I can no longer use a Concept within the if-constexpr's expression.
I receive the error:
:26:58: error: expected unqualified-id before ')' token

Compiler Explorer link: https://godbolt.org/z/r8TXSM

Assuming it is not due to an intended change in concepts for c++20, as Clang
appears to support it when compiled with concepts branch:
https://godbolt.org/z/4liykV

Workaround exists by assigning Concept evaluation to a constexpr bool and using
that in the if-constexpr check.

In case Compiler Explorer link is insufficient, here is gcc params:
Using:
gcc 9.1.0
flags: -std=c++2a -fconcepts -O2 -Wall -Wextra -Werror -Wpedantic -Wconversion

Code:
#include 

template
concept HasInit = requires(T t, Params... p) { t.init(p...); };

struct Initable { void init(int) { std::cout << "In init" << std::endl; } };
struct Createable { void create(int) { std::cout << "In create" << std::endl; }
};

struct Foo{
template
void for_each(CB&& cb)
{
Initable i;
Createable c;
cb(i);
cb(c);
}

Foo()
{
struct Bar { int x; };
for_each(
[&](auto& foo){
// constexpr bool has_init = HasInit;
// if constexpr (has_init)
if constexpr (HasInit)
{
foo.init(5);
}
});
}
};

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

[Bug c++/81971] New: internal compiler error: in check_noexcept_r, at cp/except.c:1028

2017-08-24 Thread rwdougla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81971

Bug ID: 81971
   Summary: internal compiler error: in check_noexcept_r, at
cp/except.c:1028
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rwdougla at gmail dot com
  Target Milestone: ---

int foo(int) { return 0; }

template
struct Foo
{
bool val = requires {
{foo(T{})} -> int;
};
};

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


using gcc 7.2 with --std=c++1z --concepts -Wall
https://godbolt.org/g/kC6QpW

[Bug c++/82171] New: Cant use std::declval in concept testing map operator[]

2017-09-10 Thread rwdougla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82171

Bug ID: 82171
   Summary: Cant use std::declval in concept testing map
operator[]
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rwdougla at gmail dot com
  Target Milestone: ---

static_assert fires inside c++/7.2.0/type_traits:2259:7

Godbolt link: https://godbolt.org/g/raan9j

Pasted here: (compiler flags are -std=c++1z -fconcepts)
#include 
#include 
#include 

template
concept bool MapLike = requires(T t) {
{t[std::declval()]}
-> typename T::value_type::second_type;
};

void test(MapLike T) {}

#include 
#include 

int main() {
test(std::map{});
//test(std::vector>{});
}


Workaround requires bankshot through nested requirement:
https://godbolt.org/g/j7kuKF

#include 
#include 
#include 

template
concept bool HasIndexOp = requires (MapT t, ValueT v) {
{ t[v] } -> typename MapT::value_type::second_type;
};

template
concept bool MapLike = requires(T t) {
requires HasIndexOp;
};

void test(MapLike T) {}

#include 
#include 

int main() {
test(std::map{});
//test(std::vector>{});
}

[Bug c++/82171] Cant use std::declval in concept testing map operator[]

2017-09-10 Thread rwdougla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82171

--- Comment #1 from Robert Douglas  ---
I came about this, transitioning from habits using SFINAE. I have just realized
I can simplify it to:
template
concept bool MapLike = requires(T t) {
{t[typename T::value_type::first_type{}]}
-> typename T::value_type::second_type;
};

and bypass the declval, altogether. Question, though, does anything forbid
declval in this context?