[Bug c++/95324] New: Segmentation fault when using variadic lambda template in concept definition

2020-05-25 Thread ivan.pogrebnyak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95324

Bug ID: 95324
   Summary: Segmentation fault when using variadic lambda template
in concept definition
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ivan.pogrebnyak at gmail dot com
  Target Milestone: ---

Created attachment 48600
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48600=edit
gcc version, output, and -save-temps

Definition of the following concept (using C++20) causes segmentation fault in
GCC 10.1.0.

template 
concept Applyable =
  [](std::index_sequence) {
return std::is_invocable_v...>;
  }(std::make_index_sequence>{});

Refactoring the definition into a `constexpr bool` and using it in the concept
definition works.

See the attachment for details.

[Bug c++/82165] New: Operator overloading doesn't work with enum bit fields

2017-09-09 Thread ivan.pogrebnyak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82165

Bug ID: 82165
   Summary: Operator overloading doesn't work with enum bit fields
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ivan.pogrebnyak at gmail dot com
  Target Milestone: ---

Here's a short test program that illustrates the issue:

#include 

#define TEST(var) std::cout << #var " = " << var << std::endl;

struct flags {
  enum field { f0, f1, no_field };
  field b0 : 4;
  field b1 : 4;
  field a0, a1;
};

inline bool operator!(flags::field f) {
  std::cout << "(!) ";
  return f == flags::no_field;
}

int main() {
  flags f;
  f.b0 = flags::f0;
  f.b1 = flags::f1;
  f.a0 = flags::f0;
  f.a1 = flags::f1;

  std::cout << " test enum values" << std::endl;

  TEST( flags::f0 ) // 0
  TEST( flags::f1 ) // 1
  TEST( flags::no_field ) // 2
  TEST( !flags::f0 ) // (!) 0
  TEST( !flags::f1 ) // (!) 0
  TEST( !flags::no_field ) // (!) 1

  std::cout << "\n test regular members" << std::endl;

  TEST( f.a0 ) // 0
  TEST( f.a1 ) // 1
  TEST( !f.a0 ) // (!) 0
  TEST( !f.a1 ) // (!) 0

  std::cout << "\n test bit field members" << std::endl;

  TEST( f.b0 ) // 0
  TEST( f.b1 ) // 1
  TEST( !f.b0 ) // expected "(!) 0", but got "1"
  TEST( !f.b1 ) // expected "(!) 0", but got "0"
}

As can be seen from the output of the tests with bit field members, the "(!)"
is not printed, and the integral values are negated, rather then compared to
the `flags::no_field`.

This doesn't appear to be a recently introduced bug, as I got the same behavior
using GCC 7.2.0, 6.3.0, 5.4.0, and 4.8.1.