Size: a a a

2020 October 30

NS

Nikolai Sinyov in pro.cxx
Сейчас распишу стэктрейс
источник

ПК

Побитый Кирпич... in pro.cxx
Убери вообще const из возвращаемого значения
источник

NS

Nikolai Sinyov in pro.cxx
    basic_string() noexcept(is_nothrow_default_constructible_v<_Alty>) : _Mypair(_Zero_then_variadic_args_t{}) {
       _Mypair._Myval2._Alloc_proxy(_GET_PROXY_ALLOCATOR(_Alty, _Getal()));
       _Tidy_init();
   }


вотом
идет


   void _Alloc_proxy(_Alloc&& _Al) {
       _Container_proxy* const _New_proxy = _Unfancy(_Al.allocate(1));
       _Construct_in_place(*_New_proxy, this);
       _Myproxy            = _New_proxy;
       _New_proxy->_Mycont = this;
   }


   _NODISCARD declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) {
       return static_cast<_Ty*>(_Allocate<_New_alignof<_Ty>>(_Get_size_of_n<sizeof(_Ty)>(_Count)));
   }


template <size_t _Align, class _Traits = _Default_allocate_traits,
   enable_if_t<(!_HAS_ALIGNED_NEW || _Align <=
STDCPP_DEFAULT_NEW_ALIGNMENT), int> = 0>
declspec(allocator) void* _Allocate(const size_t _Bytes) {
   // allocate _Bytes when !_HAS_ALIGNED_NEW || _Align <= STDCPP_DEFAULT_NEW_ALIGNMENT
#if defined(_M_IX86) || defined(_M_X64)
   if (_Bytes >= _Big_allocation_threshold) { // boost the alignment of big allocations to help autovectorization
       return _Allocate_manually_vector_aligned<_Traits>(_Bytes);
   }
#endif // defined(_M_IX86) || defined(_M_X64)

   if (_Bytes != 0) {
       return _Traits::_Allocate(_Bytes);
   }

   return nullptr;
}


struct _Default_allocate_traits {
   __declspec(allocator) static void* _Allocate(const size_t _Bytes) {
       return ::operator new(_Bytes);
   }
источник

ПК

Побитый Кирпич... in pro.cxx
Nikolai Sinyov
    basic_string() noexcept(is_nothrow_default_constructible_v<_Alty>) : _Mypair(_Zero_then_variadic_args_t{}) {
       _Mypair._Myval2._Alloc_proxy(_GET_PROXY_ALLOCATOR(_Alty, _Getal()));
       _Tidy_init();
   }


вотом
идет


   void _Alloc_proxy(_Alloc&& _Al) {
       _Container_proxy* const _New_proxy = _Unfancy(_Al.allocate(1));
       _Construct_in_place(*_New_proxy, this);
       _Myproxy            = _New_proxy;
       _New_proxy->_Mycont = this;
   }


   _NODISCARD declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) {
       return static_cast<_Ty*>(_Allocate<_New_alignof<_Ty>>(_Get_size_of_n<sizeof(_Ty)>(_Count)));
   }


template <size_t _Align, class _Traits = _Default_allocate_traits,
   enable_if_t<(!_HAS_ALIGNED_NEW || _Align <=
STDCPP_DEFAULT_NEW_ALIGNMENT), int> = 0>
declspec(allocator) void* _Allocate(const size_t _Bytes) {
   // allocate _Bytes when !_HAS_ALIGNED_NEW || _Align <= STDCPP_DEFAULT_NEW_ALIGNMENT
#if defined(_M_IX86) || defined(_M_X64)
   if (_Bytes >= _Big_allocation_threshold) { // boost the alignment of big allocations to help autovectorization
       return _Allocate_manually_vector_aligned<_Traits>(_Bytes);
   }
#endif // defined(_M_IX86) || defined(_M_X64)

   if (_Bytes != 0) {
       return _Traits::_Allocate(_Bytes);
   }

   return nullptr;
}


struct _Default_allocate_traits {
   __declspec(allocator) static void* _Allocate(const size_t _Bytes) {
       return ::operator new(_Bytes);
   }
И чему равно _Bytes?
источник

NS

Nikolai Sinyov in pro.cxx
Побитый Кирпич
И чему равно _Bytes?
В отладчике выводит 16
источник

ПК

Побитый Кирпич... in pro.cxx
И потом кидается bad_alloc?
источник

NS

Nikolai Sinyov in pro.cxx
Побитый Кирпич
И потом кидается bad_alloc?
ага на return ::operator new(_Bytes);
источник

ПК

Побитый Кирпич... in pro.cxx
Прям bad_alloc? Чем докажешь?
источник

ПК

Побитый Кирпич... in pro.cxx
Короче странно всё это. Я пока не пойму как с SSO в дефолтном конструкторе может быть дин. аллокация.
источник

D

Dmitriy in pro.cxx
Nikolai Sinyov
const std::string logText(const char logRxTx[], const char  logInOut[], const char text[])
{

   std::string tmpCharLog;

   return tmpCharLog;
}

Больше
нечего удалять
Функция не static часом?
источник

NS

Nikolai Sinyov in pro.cxx
Побитый Кирпич
Короче странно всё это. Я пока не пойму как с SSO в дефолтном конструкторе может быть дин. аллокация.
так и я не понимаю.
источник

ПК

Побитый Кирпич... in pro.cxx
Dmitriy
Функция не static часом?
А какая разница?
источник

D

Dmitriy in pro.cxx
Побитый Кирпич
А какая разница?
Я баг такой на MSVC ловил.
источник

NS

Nikolai Sinyov in pro.cxx
Побитый Кирпич
Прям bad_alloc? Чем докажешь?
Сюда фото вставлять нельзя же. Показал бы тогда терйс который идет
источник

D

Dmitriy in pro.cxx
Не один в один, но отдаленно похожий.
источник

ПК

Побитый Кирпич... in pro.cxx
Nikolai Sinyov
Сюда фото вставлять нельзя же. Показал бы тогда терйс который идет
Я имею ввиду там с++ исключение std::bad_alloc?
источник

ПК

Побитый Кирпич... in pro.cxx
Поймай в try catch чтоб убедиться
источник

NS

Nikolai Sinyov in pro.cxx
Побитый Кирпич
Я имею ввиду там с++ исключение std::bad_alloc?
Исключение там идет по оператору new
источник

ПК

Побитый Кирпич... in pro.cxx
Nikolai Sinyov
Исключение там идет по оператору new
И что?
источник

ПК

Побитый Кирпич... in pro.cxx
Какое исключение?
источник