[Bug libstdc++/101091] New: std::views::take and std::views::drop are overconstrained

2021-06-16 Thread j.galecki11 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101091

Bug ID: 101091
   Summary: std::views::take and std::views::drop are
overconstrained
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: j.galecki11 at gmail dot com
  Target Milestone: ---

[Bug libstdc++/101091] std::views::take and std::views::drop are overconstrained

2021-06-16 Thread j.galecki11 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101091

--- Comment #1 from Jakub Gałecki  ---
Consider the following example: https://godbolt.org/z/YYzqWaM9G

#include 
#include 
#include 

void copy_drop_n1(const std::vector& src, std::vector& dest,
  std::size_t n) {  // size_t - narrowing conversion
  std::ranges::copy(src | std::views::drop(n), begin(dest) + n);
}

void copy_drop_n2(const std::vector& src, std::vector& dest,
  std::ptrdiff_t n) {  // ptrdiff_t
  std::ranges::copy(src | std::views::drop(n), begin(dest) + n);
}

As per the standard [range.take.overview]:
The name views​::​take denotes a range adaptor object ([range.adaptor.object]).
Let E and F be expressions, let T be remove_­cvref_­t, and let D
be range_­difference_­t. If decltype((F)) does not model
convertible_­to, views​::​take(E, F) is ill-formed. Otherwise, the
expression views​::​take(E, F) is expression-equivalent to [...]

The example above should therefore compile for size_t as well as ptrdiff_t,
since size_t is convertible to ptrdiff_t. This is a regression from libstdc++
version 10.x, where both functions compile.

[Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs

2022-03-30 Thread j.galecki11 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110

Bug ID: 105110
   Summary: NTTP type deduction fails when dependent of previous
NTTPs
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: j.galecki11 at gmail dot com
  Target Milestone: ---

Consider the following minimal example:
```
template 
struct S {};

template 
struct V {};

template  s>
void foo(V) {}

void bar() {
constexpr S<1> s;
foo(V{});
}
```
CE link for the reader's convenience: https://godbolt.org/z/1cYK9s1Ta

GCC fails to compile this (consistent across versions), complaining about
cv-qualifier mismatch, which seems wholly irrelevant. Clang compiles without
warnings.
The problem is that when instantiating a function parametrized with a NTTP, GCC
fails to deduce the type of the NTTP parameter based on the other function
parameters. This causes problems with passing around constexpr values, as shown
in the following second example: https://godbolt.org/z/3Tnjx1Wxb (again, Clang
compiles and executes as intended).

As I cannot quite figure out whether the standard requires the deduction
described above to be possible, I see 2 possibilities:
1) This is simply a bug in GCC.
2) GCC is correct in refusing to compile the provided examples (Clang is
wrong). In this case, the emitted error should probably better describe the
problem.

[Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs

2022-04-01 Thread j.galecki11 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110

--- Comment #4 from Jakub Gałecki  ---
Awesome! Happy to be of use.