[Bug libstdc++/91260] New: std::unary_function and std::binary_function still exist in C++17

2019-07-25 Thread e.tadeu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91260

Bug ID: 91260
   Summary: std::unary_function and std::binary_function still
exist in C++17
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: e.tadeu at gmail dot com
  Target Milestone: ---

When using -std=c++17 (or above), `unary_function` and `binary_function` should
not exist in the `std` namespace, but the following code still compiles:


#include 
struct F : std::binary_function {};

[Bug c++/60872] New: Cannot memcpy array of restricted pointers

2014-04-17 Thread e.tadeu at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60872

Bug ID: 60872
   Summary: Cannot memcpy array of restricted pointers
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: e.tadeu at gmail dot com

When trying to use memcpy to copy arrays of restricted pointers, it fails with
the message:


  error: '__restrict_' qualifiers cannot be applied to 'void'


This is a failing testcase:

#include 
#include 

typedef double* __restrict__ T;

void do_copy(T* a, const T* b)
{
memcpy(a, b, sizeof(T) * 3);
}

int main()
{
double x[3] = {1.5, 2.5, 3.5};

double *p0[3] = {&x[2], &x[1], &x[0]};
double *p1[3];

do_copy(p1, p0);

std::cout << *p1[2] << std::endl;

return 0;
}


[Bug libstdc++/106067] New: Error on implicit conversion to std::function: 'static constexpr bool std::_Function_handler<...>...' used before its definition

2022-06-23 Thread e.tadeu at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106067

Bug ID: 106067
   Summary: Error on implicit conversion to std::function: 'static
constexpr bool std::_Function_handler<...>...' used
before its definition
   Product: gcc
   Version: 11.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: e.tadeu at gmail dot com
  Target Milestone: ---

The following code started failing on GCC 11.3 (also fails on GCC 12):

#include 

double fn();

template )>
void caller()
{
auto f = T(fn);
// auto f = T(std::function(fn));  // workaround (this works)
}


The snippet is also here: https://godbolt.org/z/zh7nr7vKc

The full error is:

In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/move.h:57,
 from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/stl_function.h:60,
 from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:49,
 from :1:
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits: In
instantiation of 'struct std::is_trivially_copyable':
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:69:12:
  required from 'struct std::__is_location_invariant'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:125:38:
  required from 'const bool std::_Function_base::_Base_manager::__stored_locally'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:130:8:
  required from 'class std::_Function_base::_Base_manager'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:260:11:
  required from 'class std::_Function_handler'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:65:
  required from 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with
_Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes = {}]'
:8:15:   required from here
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
non-constant condition for static assertion
  713 |  
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
  |
~~~^~~~
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
'constexpr std::true_type
std::__is_complete_or_unbounded(std::__type_identity<_Tp>) [with _Tp = double
(*)(); long unsigned int  = 8; std::true_type =
std::integral_constant]' used before its definition
In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:59,
 from :1:
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h: In
instantiation of 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&)
[with _Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes =
{}]':
:8:15:   required from here
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:72:
error: 'static constexpr bool std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_S_nothrow_init() [with _Fn = double (*)(); _Res = double; _Functor
= double (*)(); _ArgTypes = {}]' used before its definition
  436 | noexcept(_Handler<_Functor>::template
_S_nothrow_init<_Functor>())
  | 
~~^~
ASM generation compiler returned: 1
In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/move.h:57,
 from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/stl_function.h:60,
 from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:49,
 from :1:
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits: In
instantiation of 'struct std::is_trivially_copyable':
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:69:12:
  required from 'struct std::__is_location_invariant'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:125:38:
  required from 'const bool std::_Function_base::_Base_manager::__stored_locally'
   
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:130:8:
  required from 'class std: