Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Valgrind显示无效的读/写错误,但我没有';t使用new或calloc,仅使用向量和固定数组_C++_C++11_Vector_Valgrind - Fatal编程技术网

C++ Valgrind显示无效的读/写错误,但我没有';t使用new或calloc,仅使用向量和固定数组

C++ Valgrind显示无效的读/写错误,但我没有';t使用new或calloc,仅使用向量和固定数组,c++,c++11,vector,valgrind,C++,C++11,Vector,Valgrind,我在我的项目中有一个类,主要存储std::vector元素,应该能够将对象的二进制表示形式存储到光盘或从光盘加载。当一个对象加载一个文件时,它会将元素数读入一个变量,然后将存储的元素读入一个数组。从这个数组中,它将元素推入向量成员。我让C++处理内存,就像我没有明确地调用 CaloC或新< /COD>。尽管工作正常,Valgrind给了我一些关于无效读写的错误消息,我不理解。它们似乎起源于类析构函数,但由于类只有std::vector元素是“动态”的,我不应该在其中做任何事情,或者我应该这样做吗

我在我的项目中有一个类,主要存储
std::vector
元素,应该能够将对象的二进制表示形式存储到光盘或从光盘加载。当一个对象加载一个文件时,它会将元素数读入一个变量,然后将存储的元素读入一个数组。从这个数组中,它将元素推入向量成员。我让C++处理内存,就像我没有明确地调用<代码> CaloC或<代码>新< /COD>。尽管工作正常,Valgrind给了我一些关于无效读写的错误消息,我不理解。它们似乎起源于类析构函数,但由于类只有
std::vector
元素是“动态”的,我不应该在其中做任何事情,或者我应该这样做吗

这是一个有效的示例:

#include <vector>
#include <string>
#include <fstream>
#include <iostream>

class Test {
    public:
        Test() {}
        ~Test() {}

        void add(std::string s) { v.push_back(s); }
        std::vector<std::string>& get() { return v; }

        void store(char const* path) {
            std::ofstream file(path, std::ios_base::out | std::ios_base::binary);
            unsigned int n = v.size();
            file.write((char*) &n, sizeof(unsigned int));
            file.write((char*) v.data(), n*sizeof(std::string));
            file.close();
        }

        void read(char const* path) {
            std::ifstream file(path, std::ios_base::in | std::ios_base::binary);
            unsigned int n;
            file.read((char*) &n, sizeof(unsigned int));
            std::string in_v[n];
            file.read((char*) in_v, n*sizeof(std::string));
            v.clear();
            for (unsigned int i = 0; i < n; i++) {
                v.push_back(in_v[i]);
            }

            if (!file) { throw std::runtime_error("reading failed"); }
        }

    private:
        std::vector<std::string> v;
};

std::ostream& operator<<(std::ostream& os, Test& t) {
    for (unsigned int i = 0; i < t.get().size(); i++) {
        os << t.get()[i] << std::endl;
    }
    return os;
}

int main(int argc, char *argv[]) {
    Test a;
    a.add("foo");
    a.add("bar");

    std::cout << a << std::endl;

    a.store("file");

    //Test b;
    //b.read("file");
    //std::cout << "restored:" << std::endl << b << std::endl;

    return 0;
}
但是当我取消注释
main()
函数中的最后几行时,一切仍然正常,但是现在valgrind打印了一些消息,我不明白为什么

foo
bar

restored:
foo
bar

==4004== Invalid read of size 4
==4004==    at 0x4F04610: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c90 is 16 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== Invalid write of size 4
==4004==    at 0x4F04616: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c90 is 16 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== Invalid free() / delete / delete[] / realloc()
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c80 is 0 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== 
==4004== HEAP SUMMARY:
==4004==     in use at exit: 72,704 bytes in 1 blocks
==4004==   total heap usage: 11 allocs, 12 frees, 90,296 bytes allocated
==4004== 
==4004== LEAK SUMMARY:
==4004==    definitely lost: 0 bytes in 0 blocks
==4004==    indirectly lost: 0 bytes in 0 blocks
==4004==      possibly lost: 0 bytes in 0 blocks
==4004==    still reachable: 72,704 bytes in 1 blocks
==4004==         suppressed: 0 bytes in 0 blocks
==4004== Rerun with --leak-check=full to see details of leaked memory
==4004== 
==4004== For counts of detected and suppressed errors, rerun with: -v
==4004== ERROR SUMMARY: 6 errors from 3 contexts (suppressed: 0 from 0)
foo
酒吧
恢复:
福
酒吧
==4004==大小为4的读取无效
==4004==at 0x4F04610:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015B0:main(dummy.cpp:48)
==4004==地址0x5aa8c90是大小为28 free'd的块中的16个字节
==4004==at 0x4C2A184:运算符删除(void*)(在/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so中)
==4004==by 0x4F04603:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015A4:main(dummy.cpp:56)
==4004== 
==4004==大小为4的写入无效
==4004==at 0x4F04616:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015B0:main(dummy.cpp:48)
==4004==地址0x5aa8c90是大小为28 free'd的块中的16个字节
==4004==at 0x4C2A184:运算符删除(void*)(在/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so中)
==4004==by 0x4F04603:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015A4:main(dummy.cpp:56)
==4004== 
==4004==无效的free()/delete/delete[]/realloc()
==4004==at 0x4C2A184:运算符删除(void*)(在/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so中)
==4004==by 0x4F04603:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015B0:main(dummy.cpp:48)
==4004==地址0x5aa8c80是大小为28 free'd的块中的0字节
==4004==at 0x4C2A184:运算符删除(void*)(在/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so中)
==4004==by 0x4F04603:std::basic_string::~basic_string()(在/usr/lib64/libstdc++.so.6.0.21中)
==4004==by 0x4026CE:void std::_Destroy(std::string*)(stl_construct.h:93)
==4004==by 0x402534:void std::_Destroy_aux:_Destroy(std::string*,std::string*)(stl_construct.h:103)
==4004==by 0x4021FD:void std::_Destroy(std::string*,std::string*)(stl_construct.h:126)
==4004==by 0x401D76:void std::_Destroy(std::string*,std::string*,std::allocator&)(stl_construct.h:151)
==4004==0x401B5B:std::vector::~vector()(stl_vector.h:424)
==4004==by 0x4016E5:Test::~Test()(dummy.cpp:9)
==4004==0x4015A4:main(dummy.cpp:56)
==4004== 
==4004== 
==4004==堆摘要:
==4004==在出口处使用:1个块中有72704个字节
==4004==总堆使用率:11个alloc,12个free,分配90296字节
foo
bar

restored:
foo
bar

==4004== Invalid read of size 4
==4004==    at 0x4F04610: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c90 is 16 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== Invalid write of size 4
==4004==    at 0x4F04616: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c90 is 16 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== Invalid free() / delete / delete[] / realloc()
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015B0: main (dummy.cpp:48)
==4004==  Address 0x5aa8c80 is 0 bytes inside a block of size 28 free'd
==4004==    at 0x4C2A184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4004==    by 0x4F04603: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.21)
==4004==    by 0x4026CE: void std::_Destroy<std::string>(std::string*) (stl_construct.h:93)
==4004==    by 0x402534: void std::_Destroy_aux<false>::__destroy<std::string*>(std::string*, std::string*) (stl_construct.h:103)
==4004==    by 0x4021FD: void std::_Destroy<std::string*>(std::string*, std::string*) (stl_construct.h:126)
==4004==    by 0x401D76: void std::_Destroy<std::string*, std::string>(std::string*, std::string*, std::allocator<std::string>&) (stl_construct.h:151)
==4004==    by 0x401B5B: std::vector<std::string, std::allocator<std::string> >::~vector() (stl_vector.h:424)
==4004==    by 0x4016E5: Test::~Test() (dummy.cpp:9)
==4004==    by 0x4015A4: main (dummy.cpp:56)
==4004== 
==4004== 
==4004== HEAP SUMMARY:
==4004==     in use at exit: 72,704 bytes in 1 blocks
==4004==   total heap usage: 11 allocs, 12 frees, 90,296 bytes allocated
==4004== 
==4004== LEAK SUMMARY:
==4004==    definitely lost: 0 bytes in 0 blocks
==4004==    indirectly lost: 0 bytes in 0 blocks
==4004==      possibly lost: 0 bytes in 0 blocks
==4004==    still reachable: 72,704 bytes in 1 blocks
==4004==         suppressed: 0 bytes in 0 blocks
==4004== Rerun with --leak-check=full to see details of leaked memory
==4004== 
==4004== For counts of detected and suppressed errors, rerun with: -v
==4004== ERROR SUMMARY: 6 errors from 3 contexts (suppressed: 0 from 0)
file.read((char*) in_v, n*sizeof(std::string));