0

I'm getting the following error when compiling my app with gcc 8.3.0

In file included from /usr/include/x86_64-linux-gnu/c++/8/bits/c++allocator.h:33,
                 from /usr/include/c++/8/bits/allocator.h:46,
                 from /usr/include/c++/8/string:41,
                 from base_types.hpp:13,
                 from queues.hpp:11,
                 from data_processing_thread.hpp:12,
                 from data_processing_thread.cpp:10:
/usr/include/c++/8/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::destroy(_Up*) [with _Up = unsigned char [1024]; _Tp = std::_List_node<unsigned char [1024]>]’:
/usr/include/c++/8/bits/alloc_traits.h:487:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::destroy(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*) [with _Up = unsigned char [1024]; _Tp = std::_List_node<unsigned char [1024]>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_List_node<unsigned char [1024]> >]’
/usr/include/c++/8/bits/list.tcc:77:31:   required from ‘void std::__cxx11::_List_base<_Tp, _Alloc>::_M_clear() [with _Tp = unsigned char [1024]; _Alloc = std::allocator<unsigned char [1024]>]’
/usr/include/c++/8/bits/stl_list.h:507:9:   required from ‘std::__cxx11::_List_base<_Tp, _Alloc>::~_List_base() [with _Tp = unsigned char [1024]; _Alloc = std::allocator<unsigned char [1024]>]’
/usr/include/c++/8/bits/stl_list.h:681:7:   required from here
/usr/include/c++/8/ext/new_allocator.h:140:28: error: request for member ‘~unsigned char [1024]’ in ‘* __p’, which is of non-class type ‘unsigned char [1024]’
  destroy(_Up* __p) { __p->~_Up(); }
                      ~~~~~~^~~
Makefile:19: recipe for target 'obj/data_processing_thread.o' failed

Line 13 of base_types.hpp, which is the first line of my code where on the error stack is just an include statement:

#include <string>

So i'm not really sure where or why this is breaking. Thanks

user2635088
  • 1,598
  • 1
  • 24
  • 43
  • 3
    The error seems to be triggered by `data_processing_thread.cpp:10`, not `base_types.hpp`. Show what is being `new`d there. – underscore_d Jan 16 '20 at 12:47
  • @underscore_d that line just the include statement for data_processing_thread.hpp, i.e. '#include "data_processing_thread.hpp"' – user2635088 Jan 16 '20 at 12:53
  • Do you have an `unsigned char [1024]` in your code somewhere? – ChrisMM Jan 16 '20 at 12:56
  • 1
    You should be able to reduce this down further. If the issue is an `#include ` then isolate it to that and present it as [mcve], together with the compile flags used. But be sure that you can actually reproduce the issue with just the `#include `. – Max Langhof Jan 16 '20 at 12:56
  • @ChrisMM I do, 'using pending_pkts_t = std::list;' where max_packet_size is 1024. Though I can't seem to make the connection with – user2635088 Jan 16 '20 at 13:09
  • @MaxLanghof I commented out all the string references in the file base_types.hpp, now the error stack becomes: `In file included from /usr/include/x86_64-linux-gnu/c++/8/bits/c++allocator.h:33, from /usr/include/c++/8/bits/allocator.h:46, from /usr/include/c++/8/string:41, from /usr/include/c++/8/bitset:47, from /usr/include/c++/8/regex:39, from ../utils/string_utils.hpp:17,' where line 17 of string_utils.hpp is #include . – user2635088 Jan 16 '20 at 13:15
  • 2
    @user2635088 Then the problem is clear (even though the error is not): You can't store arrays in `std::list`. PS: Surround inline code with backtics (`\``) to get code formatting. – Max Langhof Jan 16 '20 at 13:17
  • related/dupe: https://stackoverflow.com/questions/826935/how-do-i-store-arrays-in-an-stl-list – NathanOliver Jan 16 '20 at 13:18
  • @MaxLanghof Interesting, this was allowed in gcc4.9.3 and also gcc5.5.0? Since the code compiles and works well in these older versions of gcc. – user2635088 Jan 16 '20 at 13:59

0 Answers0