From: Daniel P. <dp...@gm...> - 2013-11-01 15:39:09
|
Great, thanks! Dan On Fri, Nov 1, 2013 at 8:05 AM, Ho Yin Chan <ric...@gm...> wrote: > Yes, it does. There are some other places in the source code which required > changes to in order to support C++11 compatiability. > > I just commited a version which I have tested with GCC4.4 (w/o C++11) and > GCC4.7 (with and w/o -std=c++11 flag). > > A patch will need to solve the openfst parenthese issue when C++11 > compilation flag seen. > > Ricky > > On 2013/11/1 上午1:09, "Daniel Povey" <dp...@gm...> wrote: >> >> Could you please try >> std::pair<typename MapType::iterator, bool> pr = >> map_.insert(typename MapType::value_type(cur_key_, holder_)); >> which I think has a better chance of being back compatible? >> Dan >> >> >> On Thu, Oct 31, 2013 at 1:01 PM, Ho Yin Chan <ric...@gm...> >> wrote: >> > Hi Dan, >> > >> > The patch from Marcin (std::make_pair) does pass my g++ (GCC) 4.4.7 >> > compiler >> > and run fine with Kaldi "make test". Yet, I can't tell if it works on >> > others version. Regarding c++11, I think I need to update my compiler >> > first >> > to gcc 4.7 first before anything can be figure out. >> > >> > Ricky >> > >> > >> > >> > On Thu, Oct 31, 2013 at 11:33 PM, Daniel Povey <dp...@gm...> wrote: >> >> >> >> Actually, on second thoughts, I think we can apply the Kaldi fix, just >> >> with an #ifdef. >> >> Ricky, for the fix below regarding std::make_pair, do you think you >> >> could figure out what the #ifdef we need to detect c++11 is, and put a >> >> fix inside an #ifdef? >> >> Dan >> >> >> >> >> >> On Thu, Oct 31, 2013 at 11:32 AM, Daniel Povey <dp...@gm...> >> >> wrote: >> >> > Thanks for the info. >> >> > Keywords for internet search: kaldi openfst c++11 compilation. >> >> > I'm quite surprised that those parentheses are necessary in OpenFst-- >> >> > surely when transitioning to c++11 they wouldn't change operator >> >> > precedence (??!!) >> >> > Anyway, I'm cc'ing Mike Riley, regarding the OpenFst issues. >> >> > >> >> > I don't think I can apply the patch to Kaldi, because with that >> >> > change >> >> > it wouldn't compile in regular c++ (unless you tested it and found >> >> > that it did). I think I put the template arguments to std::make_pair >> >> > because it woudln't compile without them, otherwise I would never do >> >> > that. >> >> > Dan >> >> > >> >> > >> >> > On Thu, Oct 31, 2013 at 11:27 AM, tvarog <tv...@us...> wrote: >> >> >> ________________________________ >> >> >> >> >> >> [bugs:#8] C++11 compatibility >> >> >> >> >> >> Status: open >> >> >> Labels: c++11 >> >> >> Created: Thu Oct 31, 2013 03:27 PM UTC by tvarog >> >> >> Last Updated: Thu Oct 31, 2013 03:27 PM UTC >> >> >> Owner: nobody >> >> >> >> >> >> Kaldi does not compile with -std=c++11 flag >> >> >> >> >> >> In file included from ../../kaldi-3123/src/util/kaldi-table.h:426:0, >> >> >> from ../../kaldi-3123/src/util/table-types.h:24, >> >> >> from ../../kaldi-3123/src/sgmm2/am-sgmm2.h:35, >> >> >> from asr-server.cpp:20: >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h: In instantiation of >> >> >> 'bool >> >> >> >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::FindKeyInternal(const >> >> >> string&, const T**) [with Holder = kaldi::TokenHolder; std::string = >> >> >> std::basic_string<char>; >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::T = >> >> >> std::basic_string<char>]': >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1932:37: required from >> >> >> 'bool >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::HasKey(const >> >> >> string&) [with Holder = kaldi::TokenHolder; std::string = >> >> >> std::basic_string<char>]' >> >> >> asr-server.cpp:842:1: required from here >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: error: no >> >> >> matching >> >> >> function for call to 'make_pair(std::string&, kaldi::TokenHolder*&)' >> >> >> map_.insert(std::make_pair<std::string, >> >> >> Holder*>(cur_key_,holder_)); >> >> >> >> >> >> ^ >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: candidate >> >> >> is: >> >> >> In file included from >> >> >> /usr/include/c++/4.8.1/bits/stl_algobase.h:64:0, >> >> >> from /usr/include/c++/4.8.1/bits/char_traits.h:39, >> >> >> from /usr/include/c++/4.8.1/ios:40, >> >> >> from /usr/include/c++/4.8.1/ostream:38, >> >> >> from /usr/include/c++/4.8.1/iostream:39, >> >> >> from asr-server.cpp:3: >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template<class >> >> >> _T1, >> >> >> class _T2> constexpr std::pair<typename >> >> >> std::__decay_and_strip<_Tp>::__type, >> >> >> typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, >> >> >> _T2&&) >> >> >> make_pair(_T1&& __x, _T2&& __y) >> >> >> ^ >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template >> >> >> argument >> >> >> deduction/substitution failed: >> >> >> In file included from ../../kaldi-3123/src/util/kaldi-table.h:426:0, >> >> >> from ../../kaldi-3123/src/util/table-types.h:24, >> >> >> from ../../kaldi-3123/src/sgmm2/am-sgmm2.h:35, >> >> >> from asr-server.cpp:20: >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: cannot >> >> >> convert >> >> >> >> >> >> >> >> >> '((kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::TokenHolder>*)this)->kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::TokenHolder>::<anonymous>.kaldi::RandomAccessTableReaderArchiveImplBase<kaldi::TokenHolder>::cur_key_' >> >> >> (type 'std::string {aka std::basic_string<char>}') to type >> >> >> 'std::basic_string<char>&&' >> >> >> map_.insert(std::make_pair<std::string, >> >> >> Holder*>(cur_key_,holder_)); >> >> >> >> >> >> ^ >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h: In instantiation of >> >> >> 'bool >> >> >> >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::FindKeyInternal(const >> >> >> string&, const T**) [with Holder = >> >> >> kaldi::KaldiObjectHolder<kaldi::Vector<float> >; std::string = >> >> >> std::basic_string<char>; >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::T = >> >> >> kaldi::Vector<float>]': >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1932:37: required from >> >> >> 'bool >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::HasKey(const >> >> >> string&) [with Holder = >> >> >> kaldi::KaldiObjectHolder<kaldi::Vector<float> >> >> >> >; >> >> >> std::string = std::basic_string<char>]' >> >> >> asr-server.cpp:842:1: required from here >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: error: no >> >> >> matching >> >> >> function for call to 'make_pair(std::string&, >> >> >> kaldi::KaldiObjectHolder<kaldi::Vector<float> >*&)' >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: candidate >> >> >> is: >> >> >> In file included from >> >> >> /usr/include/c++/4.8.1/bits/stl_algobase.h:64:0, >> >> >> from /usr/include/c++/4.8.1/bits/char_traits.h:39, >> >> >> from /usr/include/c++/4.8.1/ios:40, >> >> >> from /usr/include/c++/4.8.1/ostream:38, >> >> >> from /usr/include/c++/4.8.1/iostream:39, >> >> >> from asr-server.cpp:3: >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template<class >> >> >> _T1, >> >> >> class _T2> constexpr std::pair<typename >> >> >> std::__decay_and_strip<_Tp>::__type, >> >> >> typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, >> >> >> _T2&&) >> >> >> make_pair(_T1&& __x, _T2&& __y) >> >> >> ^ >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template >> >> >> argument >> >> >> deduction/substitution failed: >> >> >> In file included from ../../kaldi-3123/src/util/kaldi-table.h:426:0, >> >> >> from ../../kaldi-3123/src/util/table-types.h:24, >> >> >> from ../../kaldi-3123/src/sgmm2/am-sgmm2.h:35, >> >> >> from asr-server.cpp:20: >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: cannot >> >> >> convert >> >> >> >> >> >> >> >> >> '((kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::KaldiObjectHolder<kaldi::Vector<float> >> >> >>> >> >> >> >> >>> >> >> >>> >>> >>>*)this)->kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::KaldiObjectHolder<kaldi::Vector<float> >> >> >>> >> >> >> >> >>> >> >> >>> >>> >>>::<anonymous>.kaldi::RandomAccessTableReaderArchiveImplBase<kaldi::KaldiObjectHolder<kaldi::Vector<float> >> >> >>> >::cur_key_' (type 'std::string {aka std::basic_string<char>}') to >> >> >>> > type >> >> >> 'std::basic_string<char>&&' >> >> >> map_.insert(std::make_pair<std::string, >> >> >> Holder*>(cur_key_,holder_)); >> >> >> >> >> >> ^ >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h: In instantiation of >> >> >> 'bool >> >> >> >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::FindKeyInternal(const >> >> >> string&, const T**) [with Holder = >> >> >> kaldi::BasicVectorVectorHolder<int>; >> >> >> std::string = std::basic_string<char>; >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::T = >> >> >> std::vector<std::vector<int> >]': >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1932:37: required from >> >> >> 'bool >> >> >> >> >> >> kaldi::RandomAccessTableReaderUnsortedArchiveImpl<Holder>::HasKey(const >> >> >> string&) [with Holder = kaldi::BasicVectorVectorHolder<int>; >> >> >> std::string = >> >> >> std::basic_string<char>]' >> >> >> asr-server.cpp:842:1: required from here >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: error: no >> >> >> matching >> >> >> function for call to 'make_pair(std::string&, >> >> >> kaldi::BasicVectorVectorHolder<int>*&)' >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: candidate >> >> >> is: >> >> >> In file included from >> >> >> /usr/include/c++/4.8.1/bits/stl_algobase.h:64:0, >> >> >> from /usr/include/c++/4.8.1/bits/char_traits.h:39, >> >> >> from /usr/include/c++/4.8.1/ios:40, >> >> >> from /usr/include/c++/4.8.1/ostream:38, >> >> >> from /usr/include/c++/4.8.1/iostream:39, >> >> >> from asr-server.cpp:3: >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template<class >> >> >> _T1, >> >> >> class _T2> constexpr std::pair<typename >> >> >> std::__decay_and_strip<_Tp>::__type, >> >> >> typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, >> >> >> _T2&&) >> >> >> make_pair(_T1&& __x, _T2&& __y) </code> >> >> >> /usr/include/c++/4.8.1/bits/stl_pair.h:276:5: note: template >> >> >> argument >> >> >> deduction/substitution failed: >> >> >> In file included from ../../kaldi-3123/src/util/kaldi-table.h:426:0, >> >> >> from ../../kaldi-3123/src/util/table-types.h:24, >> >> >> from ../../kaldi-3123/src/sgmm2/am-sgmm2.h:35, >> >> >> from asr-server.cpp:20: >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h:1995:78: note: cannot >> >> >> convert >> >> >> >> >> >> >> >> >> '((kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::BasicVectorVectorHolder<int> >> >> >> >> >>> >> >> >>> >>> >>>*)this)->kaldi::RandomAccessTableReaderUnsortedArchiveImpl<kaldi::BasicVectorVectorHolder<int> >> >> >> >> >>> >> >> >>> >>> >>>::<anonymous>.kaldi::RandomAccessTableReaderArchiveImplBase<kaldi::BasicVectorVectorHolder<int> >> >> >>>::cur_key_' (type 'std::string {aka std::basic_string<char>}') to >> >> >>> type >> >> >> 'std::basic_string<char>&&' >> >> >> map_.insert(std::make_pair<std::string, >> >> >> Holder*>(cur_key_,holder_)); >> >> >> >> >> >> fix: >> >> >> >> >> >> ../../kaldi-3123/src/util/kaldi-table-inl.h 2013-10-31 >> >> >> 15:22:23.569000000 >> >> >> +0100 >> >> >> >> >> >> @@ -1992,7 +1990,8 @@ >> >> >> // of the object in holder_ to map_. >> >> >> // Insert it into map_. >> >> >> std::pair<typename MapType::iterator, bool> pr = >> >> >> - map_.insert(std::make_pair<const std::string, >> >> >> Holder*>(cur_key_, >> >> >> - >> >> >> holder_)); >> >> >> + map_.insert(std::make_pair(cur_key_,holder_)); >> >> >> if (!pr.second) { // Was not inserted-- previous element >> >> >> w/ >> >> >> same >> >> >> key >> >> >> delete holder_; // map was not changed, no ownership >> >> >> transferred. >> >> >> KALDI_ERR << "Error in RandomAccessTableReader: duplicate >> >> >> key " >> >> >> >> >> >> also, openfst does not compile with -std=c++11 flag (template >> >> >> argument >> >> >> deduction/substitution failed), fix: >> >> >> >> >> >> ../../kaldi-3123/tools/openfst/include/fst/interval-set.h >> >> >> 2013-10-31 >> >> >> 15:02:51.723000000 +0100 >> >> >> >> >> >> @@ -218,7 +218,7 @@ >> >> >> interval.end = min(it1->end, it2->end); >> >> >> ointervals->push_back(interval); >> >> >> oset->count_ += interval.end - interval.begin; >> >> >> - if (it1->end < it2->end) >> >> >> + if ((it1->end) < (it2->end)) >> >> >> ++it1; >> >> >> else >> >> >> ++it2; >> >> >> @@ -240,14 +240,14 @@ >> >> >> it != intervals_.end(); >> >> >> ++it) { >> >> >> interval.end = min(it->begin, maxval); >> >> >> - if (interval.begin < interval.end) { >> >> >> + if ((interval.begin) < (interval.end)) { >> >> >> ointervals->push_back(interval); >> >> >> oset->count_ += interval.end - interval.begin; >> >> >> } >> >> >> interval.begin = it->end; >> >> >> } >> >> >> interval.end = maxval; >> >> >> - if (interval.begin < interval.end) { >> >> >> + if ((interval.begin) < (interval.end)) { >> >> >> ointervals->push_back(interval); >> >> >> oset->count_ += interval.end - interval.begin; >> >> >> } >> >> >> @@ -348,7 +348,7 @@ >> >> >> while (it1 != intervals_.end() && it2 != intervals->end()) { >> >> >> if (it1->end <= it2->begin) { // no overlap - it1 first >> >> >> ++it1; >> >> >> - } else if (it2->begin < it1->begin || it2->end > it1->end) { >> >> >> // >> >> >> no C >> >> >> + } else if ((it2->begin) < (it1->begin) || (it2->end) > >> >> >> (it1->end)) >> >> >> { >> >> >> // no C >> >> >> return false; >> >> >> } else if (it2->end == it1->end) { >> >> >> ++it1; >> >> >> >> >> >> Marcin >> >> >> >> >> >> ________________________________ >> >> >> >> >> >> Sent from sourceforge.net because you indicated interest in >> >> >> https://sourceforge.net/p/kaldi/bugs/8/ >> >> >> >> >> >> To unsubscribe from further messages, please visit >> >> >> https://sourceforge.net/auth/subscriptions/ >> > >> > |