Diagnostics detected issues [cpp.g++17-drmemory]: ~~Dr.M~~ Dr. Memory version 1.11.0
~~Dr.M~~ Running "program.exe"
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
C:/Programs/mingw-w64-7/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/debug/deque:485:
Error: attempt to insert with an iterator range [__first, __last) from this
container.
Objects involved in the operation:
iterator "__first" @ 0x105BFE08 {
type = __gnu_debug::_Safe_iterator<std::__cxx1998::_Deque_iterator<char, char&, char*>, std::__debug::deque<char, std::allocator<char> > > (mutable iterator);
state = dereferenceable (start-of-sequence);
references sequence with type 'std::__debug::deque<char, std::allocator<char> >' @ 0x105BFD6C
}
iterator "__last" @ 0x105BFDC8 {
type = __gnu_debug::_Safe_iterator<std::__cxx1998::_Deque_iterator<char, char&, char*>, std::__debug::deque<char, std::allocator<char> > > (mutable iterator);
state = past-the-end;
references sequence with type 'std::__debug::deque<char, std::allocator<char> >' @ 0x105BFD6C
}
sequence "this" @ 0x105BFD6C {
type = std::__debug::deque<char, std::allocator<char> >;
}
~~Dr.M~~
~~Dr.M~~ Error #1: POSSIBLE LEAK 60 direct bytes 0x113500f8-0x11350134 + 0 indirect bytes
~~Dr.M~~ # 0 replace_malloc [d:\drmemory_package\common\alloc_replace.c:2576]
~~Dr.M~~ # 1 msvcrt.dll!strcpy_s +0x5e (0x7689f5d3 <msvcrt.dll+0xf5d3>)
~~Dr.M~~ # 2 msvcrt.dll!clearerr_s +0x337 (0x768a9eed <msvcrt.dll+0x19eed>)
~~Dr.M~~ # 3 msvcrt.dll!clearerr_s +0x27e (0x768a9e34 <msvcrt.dll+0x19e34>)
~~Dr.M~~ # 4 pre_cpp_init
~~Dr.M~~ # 5 __tmainCRTStartup
~~Dr.M~~ # 6 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x75d9343d <KERNEL32.dll+0x1343d>)
~~Dr.M~~
~~Dr.M~~ ERRORS FOUND:
~~Dr.M~~ 0 unique, 0 total unaddressable access(es)
~~Dr.M~~ 0 unique, 0 total uninitialized access(es)
~~Dr.M~~ 0 unique, 0 total invalid heap argument(s)
~~Dr.M~~ 0 unique, 0 total GDI usage error(s)
~~Dr.M~~ 0 unique, 0 total handle leak(s)
~~Dr.M~~ 0 unique, 0 total warning(s)
~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of leak(s)
~~Dr.M~~ 1 unique, 1 total, 60 byte(s) of possible leak(s)
~~Dr.M~~ ERRORS IGNORED:
~~Dr.M~~ 2 potential error(s) (suspected false positives)
~~Dr.M~~ (details: K:\invoker-prod\work\codeforces6\95dc81b8e4ab3564919231b09be345f6\check-9dfdf4cbd29474b4e0d899a6d68375b7\run\DrMemory-program.exe.3392.000\potential_errors.txt)
~~Dr.M~~ 14 unique, 14 total, 24965 byte(s) of still-reachable allocation(s)
~~Dr.M~~ (re-run with "-show_reachable" for details)
~~Dr.M~~ Details: K:\invoker-prod\work\codeforces6\95dc81b8e4ab3564919231b09be345f6\check-9dfdf4cbd29474b4e0d899a6d68375b7\run\DrMemory-program.exe.3392.000\results.txt
~~Dr.M~~ Fetching 1 symbol files...
~~Dr.M~~ [1/1] Fetching symbols for C:\Windows\syswow64\msvcrt.dll
~~Dr.M~~ Fetched 1 symbol files successfully
~~Dr.M~~ WARNING: application exited with abnormal code 0x3
Iterators become invalidated during insertion, so
d.begin(), d.begin() + n
stops being a valid range.Alright that makes sense. But if that's the case, then why does Solution 2 pass on sample test cases all the way till test case 4?
Thank you for your response!
Bad luck. Just because some code works, doesn't mean it's correct.