[Bug c++/88795] New: ICE on class-template argument deduction if non-type parameter has indirection

2019-01-10 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

Bug ID: 88795
   Summary: ICE on class-template argument deduction if non-type
parameter has indirection
   Product: gcc
   Version: 7.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: programmer at posteo dot de
  Target Milestone: ---

The following code (compiled with g++ -std=c++17 -Wall -Wextra) causes an
internal compiler error (ICE) with all GCC versions on godbolt starting from
7.1. Clang compiles fine.

// CODE START

template
struct Array {};

template
struct Foo {
  static constexpr int size() {
  return size_;// this indirection causes the ICE
  }

  template
  Foo(U, Array) {}
};

template
Foo(U, Array) -> Foo;

int main() {
  Array arr{};

  Foo foo{2.0, arr};
}

// CODE END



Below I post the error messages from godbolt in order to make it easier to find
this report. See also https://godbolt.org/z/Nb-3YM

GCC 9.0.0 20190109: internal compiler error: tree check: expected tree_list,
have error_mark in type_hash_canon_hash, at tree.c:6811

GCC 8.2.0: internal compiler error: in type_unification_real, at cp/pt.c:20206

GCC 8.1.0: internal compiler error: in type_unification_real, at cp/pt.c:20148
[...] mmap: Invalid argument

GCC 7.4.0: internal compiler error: in type_unification_real, at cp/pt.c:19294

GCC 7.3.0: internal compiler error: in type_unification_real, at cp/pt.c:19239
[...] mmap: Invalid argument

GCC 7.2.0: internal compiler error: in type_unification_real, at cp/pt.c:19209
[...] mmap: Invalid argument

GCC 7.1.0: internal compiler error: in type_unification_real, at cp/pt.c:19127
[...] mmap: Invalid argument

[Bug c++/88815] New: [9 Regression] is_constexpr (based on narrowing conversion and expression SFINAE) broken

2019-01-11 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88815

Bug ID: 88815
   Summary: [9 Regression] is_constexpr (based on narrowing
conversion and expression SFINAE) broken
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: programmer at posteo dot de
  Target Milestone: ---

[note: following code adopted from
https://stackoverflow.com/a/50169108/2615118]

The following experiment of an "is_constexpr" implementation fails on GCC 9.

https://godbolt.org/z/xDiFet

// BEGIN CODE

struct true_type {
constexpr operator bool() const { return true; }
};

struct false_type {
constexpr operator bool() const { return false; }
};



template
true_type is_constexpr_impl(decltype(int{(p(), 0U)}));// narrowing conversion

template
false_type is_constexpr_impl(...);

template
using is_constexpr = decltype(is_constexpr_impl(0));



constexpr int f() { return 0; }
int g() { return 0; }

static_assert(is_constexpr());
static_assert(!is_constexpr());// this one fails in GCC 9.0.0 20190109

// END CODE

[Bug middle-end/91490] [9 Regression] bogus argument missing terminating nul warning on strlen of a flexible array member

2019-09-20 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490

programmer at posteo dot de changed:

   What|Removed |Added

 CC||programmer at posteo dot de

--- Comment #6 from programmer at posteo dot de ---
The same bogus warning ist produced by "g++ -Wall" with the C++ code below.
Note that flexible array members are not involved there.

GCC 9.2 is affected: https://godbolt.org/z/j9m4XS
GCC 10 seems fixed: https://godbolt.org/z/DPrR1Z

//

struct two_chars_t {// std::array
  char data_[2];
  constexpr const char* data() const { return data_; }
};

constexpr two_chars_t global_x0  = two_chars_t{'x', '\0'};

int main() {
  constexpr const char* pointer = global_x0.data();

  static_assert(pointer[0] == 'x');
  static_assert(pointer[1] == '\0');

  return __builtin_strlen(pointer);
}

//

[Bug c++/86646] New: Special member function 'cannot be defaulted' if type alias is used

2018-07-23 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86646

Bug ID: 86646
   Summary: Special member function 'cannot be defaulted' if type
alias is used
   Product: gcc
   Version: 7.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: programmer at posteo dot de
  Target Milestone: ---

GCC 7.3.0 (as well as 8.1 and 9.0 from godbolt.org) fails to compile the
following code:

//---
template
struct Foo {
  static constexpr int N = N_;// this indirection causes the error
  using Self = Foo;

  Foo(const Self&) = default;
};
//---



The error message reads

> file.cpp:6:22: error: ‘Foo::Foo(const Self&)’ cannot be defaulted



I used the following command line to obtain that error message:

> g++ -Wall -Wextra -std=c++11 file.cpp

[Bug c++/85875] -Weffc++ can't understand auto return values

2018-08-23 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85875

programmer at posteo dot de changed:

   What|Removed |Added

 CC||programmer at posteo dot de

--- Comment #1 from programmer at posteo dot de ---
Related: If the return type shall be used for SFINAE then GCC complains before
any instantiation takes place.



#include 

template struct UseOps;

template
constexpr std::enable_if_t<
  UseOps{},
  T&
> operator++(T&);



// warning: prefix 'constexpr std::enable_if_t{}, T&> operator++(T&)'
// should return 'T&' [-Weffc++]

[Bug c++/87145] New: Implicit conversion to scoped enum fails: "error: taking address of temporary/rvalue"

2018-08-29 Thread programmer at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87145

Bug ID: 87145
   Summary: Implicit conversion to scoped enum fails: "error:
taking address of temporary/rvalue"
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: programmer at posteo dot de
  Target Milestone: ---

The following code can be compiled with GCC 6.3, but GCC 7.1 and later abort
the compilation with an error message.

=

#include 

#include 

enum class Enum : std::size_t {};

struct Pod {
  std::size_t val;

  constexpr operator Enum() const {
return static_cast(val);
  }
};

template
constexpr void foo() {
  using Foo = std::integral_constant;
}

int main() {
  foo<2>();
}

=

Error message from current trunk:

=

: In instantiation of 'constexpr void foo() [with long unsigned int N =
2]':

:21:10:   required from here

:17:50: error: taking address of rvalue [-fpermissive]

17 |   using Foo = std::integral_constant;

   |  ^

:17:50: error: no matching function for call to 'Pod::operator
Enum(Pod*)'

:10:13: note: candidate: 'constexpr Pod::operator Enum() const'

10 |   constexpr operator Enum() const {

   | ^~~~

:10:13: note:   candidate expects 0 arguments, 1 provided

Compiler returned: 1

=

Live demo: https://godbolt.org/z/vfvGiS



PS: Which version should I choose if multiple versions are affected: stable,
trunk or [the first version with that regression]?