divyang4481 / mipt-hw

Automatically exported from code.google.com/p/mipt-hw
0 stars 0 forks source link

task_01 TList #264

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
\baldin_dima\task01_list

Original issue reported on code.google.com by dmitryba...@gmail.com on 25 May 2013 at 6:55

GoogleCodeExporter commented 9 years ago
1. iterator::operator--(int) возвращает ссылку на 
локальную переменную. После выхода из 
метода, этот объект не существует.
То же самое замечание для operator++ и для тех 
операторов в const_iterator.

2. Добавляю код в main():
        {
            TList<myint> a;
            for (int i = 0; i < 10; ++i)
                a.push_back(myint());

            TList<myint> b = a;
            for (int i = 0; i < 10; ++i)
                b.push_back(myint());

            TList<myint> c;
            a = c;

            c.swap(b);
        }
Запускаю. Получаю проезд по памяти и 
аварийное завершение программы.
Изменения закоммитил.

Решение не принято.

Original comment by aivyu...@gmail.com on 26 May 2013 at 2:59

GoogleCodeExporter commented 9 years ago

Original comment by dmitryba...@gmail.com on 26 May 2013 at 10:54

GoogleCodeExporter commented 9 years ago
Все равно проезд по памяти.
Я даже могу сказать на какой строчке:
        {
            TList<myint> a;
            for (int i = 0; i < 10; ++i)
                a.push_back(myint());

            TList<myint> b = a;
            for (int i = 0; i < 10; ++i)
                b.push_back(myint());

            TList<myint> c;
            a = c; // !!!!!!!!!!!!!!!!!!!!!!!!!!

            c.swap(b);
        }

Original comment by aivyu...@gmail.com on 27 May 2013 at 7:46