[Bug c++/95181] internal compiler error: in push_access_scope, at cp/pt.c:241

2020-05-17 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95181

--- Comment #3 from ahmet özhan  ---
Comment on attachment 48554
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48554
gcc 10 don't compile but clang compile

>#include 
>
>namespace math {
>   
>   template 
>   requires std::is_arithmetic_v
>   class matrix {
>   union {
>   std::array m_elements_1d;
>   std::array, Row> m_elements_2d;
>   };
>   
>   public:
>   template 
>   requires
>   std::conjunction_v...>
>   constexpr matrix(const Args&... args) noexcept
>   : m_elements_1d {{ args... }} {}
>   
>   template 
>   requires
>   std::conjunction_v, 
> Args>...>
>   constexpr matrix(const Args&... args) noexcept
>   : m_elements_2d {{ args... }} {}
>   };
>}
>
>#include 
>
>template 
>void test() {
>   
>   T f1, f2, f3, f4, f5, f6, f7, f8;
>   
>   std::cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6 >> f7 >> f8;
>   math::matrix m0(
>   std::array {{ f1, f2, f3, f4 }},
>   std::array {{ f5, f6, f7, f8 }}
>   );
>}
>
>int main(int argc, char **argv)
>{
>   test();
>   return 0;
>}

[Bug c++/95181] internal compiler error: in push_access_scope, at cp/pt.c:241

2020-05-17 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95181

--- Comment #2 from ahmet özhan  ---
Comment on attachment 48554
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48554
gcc 10 don't compile but clang compile

>#include 
>
>namespace math {
>   
>   template 
>   requires std::is_arithmetic_v
>   class matrix {
>   union {
>   std::array m_elements_1d;
>   std::array, Row> m_elements_2d;
>   };
>   
>   public:
>   template 
>   requires
>   std::conjunction_v...>
>   constexpr matrix(const Args&... args) noexcept
>   : m_elements_1d {{ args... }} {}
>   
>   template 
>   requires
>   std::conjunction_v, 
> Args>...>
>   constexpr matrix(const Args&... args) noexcept
>   : m_elements_2d {{ args... }} {}
>   };
>}
>
>#include 
>
>template 
>void test() {
>   
>   T f1, f2, f3, f4, f5, f6, f7, f8;
>   
>   std::cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6 >> f7 >> f8;
>   math::matrix m0(
>   std::array {{ f1, f2, f3, f4 }},
>   std::array {{ f5, f6, f7, f8 }}
>   );
>}
>
>int main(int argc, char **argv)
>{
>   test();
>   return 0;
>}

[Bug c++/95181] internal compiler error: in push_access_scope, at cp/pt.c:241

2020-05-17 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95181

--- Comment #1 from ahmet özhan  ---
gcc 9.3 compile

[Bug c++/95181] New: internal compiler error: in push_access_scope, at cp/pt.c:241

2020-05-17 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95181

Bug ID: 95181
   Summary: internal compiler error: in push_access_scope, at
cp/pt.c:241
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tahasuf at gmail dot com
  Target Milestone: ---

Created attachment 48554
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48554=edit
gcc 10 don't compile but clang compile

gcc 10.1
-O3 -std=c++2a -fconcepts -fanalyzer

clang10 compile

https://godbolt.org/z/Y_iYcQ

[Bug c++/93275] internal compiler error: unexpected expression 'N' of kind template_parm_index

2020-01-15 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

--- Comment #2 from ahmet özhan  ---
template  > array_depth_v),
std::nullptr_t> = nullptr>
constexpr array operator * (const Other& other) const {
array result {};
std::transform(
std::begin(*this),
std::end(*this),
std::begin(result),
[other](const T& t) { return t * other; });
return result;
}

but change this line and add -fconcepts
--
template  > array_depth_v),
std::nullptr_t> = nullptr>
-
template 
requires (array_depth_v > array_depth_v)

gcc 9.0 compile.

[Bug c++/93275] Error when calculating template parameters in recursive template function call

2020-01-15 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

--- Comment #1 from ahmet özhan  ---
: In substitution of 'template
template
> > array_depth_v), std::nullptr_t>::type  > constexpr
math::array math::array::operator*(const Other&) const [with Other
= ; typename std::enable_if<(array_depth_v > >
array_depth_v), std::nullptr_t>::type  = ; T =
float; long unsigned int N = ]':

:56:36:   required from 'constexpr math::array math::array::operator*(const Other&) const [with Other = float; typename
std::enable_if<(array_depth_v > > array_depth_v),
std::nullptr_t>::type  = nullptr; T = math::array; long
unsigned int N = 1]'

:79:20:   required from here

:48:5: internal compiler error: unexpected expression 'N' of kind
template_parm_index

   48 |(array_depth_v > array_depth_v),

  | ^~~~

Please submit a full bug report,

with preprocessed source if appropriate.

See  for instructions.

[Bug c++/93275] New: Error when calculating template parameters in recursive template function call

2020-01-15 Thread tahasuf at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93275

Bug ID: 93275
   Summary: Error when calculating template parameters in
recursive template function call
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tahasuf at gmail dot com
  Target Milestone: ---

Clang and GCC 8 can compile the code without any errors. But GCC 9 gives an
error.


#include 
#include 
#include 

namespace math {

/** forward declaration **/
template 
struct array;

/** is_array **/
template 
struct is_array: std::false_type {};

template 
struct is_array>: std::true_type {};

template 
inline constexpr bool is_array_v = is_array::value;

/** array_depth **/
template 
struct array_depth: std::integral_constant {};

template 
struct array_depth>:
std::integral_constant::value>
{};

template 
inline constexpr bool array_depth_v = array_depth::value;

/** array **/
template 
struct array: std::array {

constexpr array operator * (const array& other) const {
array result {};
std::transform(
std::begin(*this),
std::end(*this),
std::begin(other),
std::begin(result),
std::multiplies());
return result;
}

template  > array_depth_v),
std::nullptr_t> = nullptr>
constexpr array operator * (const Other& other) const {
array result {};
std::transform(
std::begin(*this),
std::end(*this),
std::begin(result),
[other](const T& t) { return t * other; });
return result;
}

friend std::ostream&
operator << (std::ostream& out, const array& source) {
out << ")
out << typeid(T).name();
for (auto it: source) {
if constexpr (!is_array_v)
out << " ";
out << it;
}
out << ">";
return out;
}
};
}

int main() {
math::array, 1> a0
{{math::array{{1.f, 2.f, 3.f, 4.f;
std::cout << a0 * 4.f << std::endl;
return 0;
}