[Bug c++/105476] internal compiler error: in build_deduction_guide

2022-05-04 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105476

--- Comment #2 from pavlick  ---
One moment, i will do reduction.

[Bug c++/105476] New: internal compiler error: in build_deduction_guide

2022-05-04 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105476

Bug ID: 105476
   Summary: internal compiler error: in build_deduction_guide
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ispavlick at gmail dot com
  Target Milestone: ---

Reference to a preprocessed file (size limits do not allow uploading here)
https://drive.google.com/file/d/1y8_Ctd0-VxdZHHhgHen2s7b2DjGpyCC8/view?usp=sharing
 

$ gcc -std=gnu++20 -x c++-cpp-output 3.ii -o res
/home/pavlick/wrk/sftable/temp/3.cpp: In function ‘int main()’:
/home/pavlick/wrk/sftable/temp/3.cpp:18:9: internal compiler error: in
build_deduction_guide, at cp/pt.c:28659
   18 | };
  | ^
0xe4c988 internal_error(char const*, ...)
???:0
0xe42d02 fancy_abort(char const*, int, char const*)
???:0
0x10358fb cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x14e7873 c_parse_file()
???:0
0x14c9d9e c_common_parse_file()
???:0
Please submit a full bug report,

[Bug c++/103313] New: nontype_argument_pack - compile error due to unsupported tree

2021-11-18 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103313

Bug ID: 103313
   Summary: nontype_argument_pack - compile error due to
unsupported tree
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ispavlick at gmail dot com
  Target Milestone: ---

#include 
#include 
using namespace std;

struct Q {
void set(int i) {}
};

template 
struct S {
Q mq[I];
template 
void f(array ,
index_sequence n=make_index_sequence{}) {
((mq[num].set(a[num])), ...);
}
};

int main() {
S<3> s;
array a{2, 5, 7};
s.f(a); // error
//s.f(a, make_index_sequence<3>{}); // ok

}

$ g++ 1.cpp -std=c++20
1.cpp: In member function ‘void S::f(std::array&,
std::index_sequence) [with long unsigned int ...num = {}; int I = 3;
std::index_sequence = std
::integer_sequence]’:
1.cpp:22:8: error: could not convert ‘std::make_index_sequence<3>{}’ from
‘integer_sequence<[...],‘nontype_argument_pack’ not supported by
dump_expr>’ to 
integer_sequence<[...],‘nontype_argument_pack’ not supported by
dump_expr>’
   22 | s.f(a);
  | ~~~^~~
  ||
  |integer_sequence<[...],‘nontype_argument_pack’ not supported by
dump_expr>
1.cpp:22:8: note:   when instantiating default argument for call to ‘void
S::f(std::array&, std::index_sequence) [with long unsigned
int ...num = {}; int
 I = 3; std::index_sequence = std::integer_sequence]’
1.cpp: In function ‘int main()’:
1.cpp:22:8: error: could not convert ‘std::make_index_sequence<3>{}’ from
‘integer_sequence<[...],‘nontype_argument_pack’ not supported by
dump_expr>’ to 
integer_sequence<[...],‘nontype_argument_pack’ not supported by
dump_expr>’

[Bug c++/102777] New: Error when requires expressions with parameter pack

2021-10-15 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102777

Bug ID: 102777
   Summary: Error when requires expressions with parameter pack
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ispavlick at gmail dot com
  Target Milestone: ---

// clang compiles without errors.
#include 
#include 
#include 
using namespace std;

template 
constexpr bool check_visitor = [](index_sequence){
return ((requires (tuple_element_t fun)
{{fun(3)}->same_as;}) && ...);
}(make_index_sequence>{});

int main() {
auto f1 = [](int) {};
auto f2 = [](int) {};
static_assert(check_visitor>);
}


$ g++ -std=c++20 1.cpp
1.cpp: In lambda function:
1.cpp:9:22: error: operand of fold expression has no unexpanded parameter packs
9 | return ((requires (tuple_element_t fun)
  | ~^~~~
   10 | {{fun(3)}->same_as;}) &&
...);
  | ~~~
1.cpp: In instantiation of ‘constexpr const bool
check_visitor, main():: > >’:
1.cpp:16:16:   required from here
1.cpp:11:2: error: void value not ignored as it ought to be
8 | constexpr bool check_visitor = [](index_sequence){
  |~~
9 | return ((requires (tuple_element_t fun)
  | ~
   10 | {{fun(3)}->same_as;}) &&
...);
  |

   11 | }(make_index_sequence>{});
  | ~^~~~
1.cpp: In function ‘int main()’:
1.cpp:16:23: error: non-constant condition for static assertion
   16 | static_assert(check_visitor>);
  |   ^~~~

[Bug sanitizer/97868] warn about using fences with TSAN

2021-09-11 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97868

pavlick  changed:

   What|Removed |Added

 CC||ispavlick at gmail dot com

--- Comment #5 from pavlick  ---
Why is there false positive and no warning about the unsupported feature
(atomic_thread_fence)?

[code]
#include 
#include 
#include 
#include 
using namespace std;

class Test {
atomic_flag m_spin_lock;
vector m_data;
public:
void add() {
while (m_spin_lock.test_and_set(memory_order_relaxed))
this_thread::yield();
atomic_thread_fence(memory_order_acquire);
while (true) {
this_thread::sleep_for(300ms);
m_data.push_back(4);
}
m_spin_lock.clear(memory_order_release);
}
void read() {
size_t sz;
if (! m_spin_lock.test_and_set(std::memory_order_acquire)) {
sz = m_data.size();
m_spin_lock.clear(std::memory_order_release);
}
(void)sz;
}
}test;

int main() {
jthread rt(::read, );
this_thread::sleep_for(10ms);
test.add();
}

[/code]

$ g++ 3.cc -std=c++20 -Wtsan -Wall -fsanitize=thread

[Bug sanitizer/101978] thread sanitizer false positive when smart pointers

2021-08-19 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101978

--- Comment #1 from pavlick  ---
Apparently this is due to condition_variable, if it is commented
//while (! cv.wait_for(lck, 1s, [_ptr](){
//  return sh_ptr->processed == true;})  &&  true);
then there are no warnings

[Bug sanitizer/101978] New: thread sanitizer false positive when smart pointers

2021-08-19 Thread ispavlick at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101978

Bug ID: 101978
   Summary: thread sanitizer false positive when smart pointers
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ispavlick at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

When it is compiled with clang then no warnings are displayed (from sanitizer).

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

struct Mes {
int data = 0;
bool processed = false;
};
struct Test {
mutex mtx;
condition_variable cv;
queue> mes_queue;
int read();
bool check();
} t;
int Test::read() {
auto sh_ptr = make_shared();
unique_lock lck{mtx};
mes_queue.push(sh_ptr);
while (! cv.wait_for(lck, 1s, [_ptr](){
return sh_ptr->processed == true;})  &&  true);
return sh_ptr->data;
}
bool Test::check() {
unique_lock lck{mtx};
bool ret = mes_queue.size();
while (mes_queue.size()) {
if (shared_ptr mes = mes_queue.front().lock()) {
mes->data = 5;
mes->processed = true;
}
mes_queue.pop();
}
cv.notify_all();
return ret;
}
void read_th() {
while (true) {
t.read();
this_thread::sleep_for(200ms);
}
}
void check_th() {
while (true) {
t.check();
this_thread::sleep_for(200ms);
}
}
int main() {
jthread tr{read_th};
jthread tc{check_th};
}

$ g++ -pthread -std=c++20 -fsanitize=thread test.cc
$ ./a.out

==
WARNING: ThreadSanitizer: double lock of a mutex (pid=76697)
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*)  (a.out+0x2df5)
#2 std::mutex::lock()  (a.out+0x2e7a)
#3 std::unique_lock::lock()  (a.out+0x56f5)
#4 std::unique_lock::unique_lock(std::mutex&) 
(a.out+0x4a32)
#5 Test::check()  (a.out+0x2628)
#6 check_th()  (a.out+0x27d7)
#7 void std::__invoke_impl(std::__invoke_other, void
(*&&)())  (a.out+0xa562)
#8 std::__invoke_result::type std::__invoke(void
(*&&)())  (a.out+0xa4b9)
#9 void std::thread::_Invoker
>::_M_invoke<0ul>(std::_Index_tuple<0ul>)  (a.out+0xa41e)
#10 std::thread::_Invoker >::operator()() 
(a.out+0xa3ae)
#11 std::thread::_State_impl >
>::_M_run()  (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)

  Location is global 't' of size 168 at 0x562d5860c1c0 (a.out+0x000111c0)

  Mutex M10 (0x562d5860c1c0) created at:
#0 pthread_mutex_lock
/build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4250
(libtsan.so.0+0x54b6a)
#1 __gthread_mutex_lock(pthread_mutex_t*)  (a.out+0x2df5)
#2 std::mutex::lock()  (a.out+0x2e7a)
#3 std::unique_lock::lock()  (a.out+0x56f5)
#4 std::unique_lock::unique_lock(std::mutex&) 
(a.out+0x4a32)
#5 Test::read()  (a.out+0x24d0)
#6 read_th()  (a.out+0x277a)
#7 void std::__invoke_impl(std::__invoke_other, void
(*&&)())  (a.out+0xa562)
#8 std::__invoke_result::type std::__invoke(void
(*&&)())  (a.out+0xa4b9)
#9 void std::thread::_Invoker
>::_M_invoke<0ul>(std::_Index_tuple<0ul>)  (a.out+0xa41e)
#10 std::thread::_Invoker >::operator()() 
(a.out+0xa3ae)
#11 std::thread::_State_impl >
>::_M_run()  (a.out+0xa300)
#12 execute_native_thread_routine
/build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:82 (libstdc++.so.6+0xd33c3)

SUMMARY: ThreadSanitizer: double lock of a mutex (/tmp/a.out+0x2df5) in
__gthread_mutex_lock(pthread_mutex_t*)
==
==
WARNING: ThreadSanitizer: data race (pid=76697)
  Read of size 8 at 0x562d5860c248 by thread T2 (mutexes: write M10):
#0 std::operator-(std::_Deque_iterator,
std::weak_ptr&, std::weak_ptr*> const&,
std::_Deque_iterator, std::weak_ptr&,
std::weak_ptr*> const&)  (a.out+0x6ba3)
#1 std::deque, std::allocator >
>::size() const  (a.out+0x5cad)
#2 std::queue, std::deque,
std::allocator > > >::size() const  (a.out+0x4c20)
#3 Test::check()  (a.out+0x2638)
#4 check_th()  (a.out+0x27d7)
#5 void std::__invoke_impl(std::__invoke_other, void
(*&&)())  (a.out+0xa562)
#6 std::__invoke_result::type std::__invoke(void
(*&&)())  (a.out+0xa4b9)
#7 void std::thread::_Invoker
>::_M_invoke<0ul>(std::_Index_tuple<0ul>)  (a.out+0xa41e)
#8