Bug 10148 - Проблема при использовании стековых переменных
Summary: Проблема при использовании стековых переменных
Status: CLOSED DUPLICATE of bug 10144
Alias: None
Product: Sisyphus
Classification: Development
Component: gcc4.1-c++ (show other bugs)
Version: unstable
Hardware: all Linux
: P2 normal
Assignee: Dmitry V. Levin
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-17 09:57 MSD by Ilia Korolyov
Modified: 2006-12-04 00:14 MSK (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilia Korolyov 2006-10-17 09:58:00 MSD
Актуальный сизиф. gcc 4.1.1 20060928 (ALT Linux, build 4.1.1-alt9)
Есть следующий код


int main( int argc, char** argv )
{
        try
        {
                boost::regex
re("(\\w+):\\/\\/(([^:]+?)(:(.+))?@)?([^:\\/]+)(:(\\d+))?((\\/.+?)*)(\\?(.+?))?(#(.+))?");
                boost::match_results<std::string::const_iterator> what;

                std::string
first("http://breeze@abc.ru/banner.jsp?keywords=%CC%E5%E3%E0%F4%EE%ED&id=1&ip=1.1.1.1&version=1#123");


                boost::regex::locale_type loc("ru_RU.cp1251");
//              re.imbue( loc );

                for( int i=0; i<5; ++i )
                {
                        if(
!boost::regex_match(boost::algorithm::trim_copy(first), what, re) ) continue;
                        cerr << "res =  " << what[12].str() << endl;

                        string tmp = boost::algorithm::trim_copy(first);
                        if( !boost::regex_match(tmp, what, re) ) continue;
                        cerr << "res2 =  " << what[12].str() << endl;
                }

                re.imbue( loc );
        }
        catch (std::exception& ex)
        {
                cerr << "UGLY STANDART ERROR: " << ex.what() << endl;
                return -1;
        }
        catch(...)
        {
                cerr << "UGLY ERROR: UNHANDLED EXCEPTION" << endl;
                return -1;
        }

        return 0;
}

Данные код просто парсит URL при помощи boost::regex, есть две проблемы:
1. Строки "res=..." и "res2=..." должны быть одинаковыми, реально получается

res =  keywords=%CC%E5%E3%E0%F4%EE%ED&iи╟Aь╥╟Aь╥.1&version=1
res2 =  keywords=%CC%E5%E3%E0%F4%EE%ED&id=1&ip=1.1.1.1&version=1

т.е. в строке "res=..." присутствует явный мусор

Подобное поведение встречается не только при работе с boost, но и с
произвольными объектами в случае, когда результат функции не сохраняется явно в
какой-то переменной, а непосредственно передаётся в другую функцию


PS Возможно я обратился не по адресу - подскажите, куда следует обратиться
Steps to Reproduce:
make && run
Comment 1 Dmitry V. Levin 2006-12-04 00:14:44 MSK

*** This bug has been marked as a duplicate of 10144 ***