narrowing conversion warning in boost's regex_traits_defaults.hpp when trying to initialize wregex object
The first line compiles ok. The second also produces working EXE, but in addition I get this large error: In file included from d:\boost/boost/regex/v4/regex_traits.hpp:35:0, from d:\boost/boost/regex/regex_traits.hpp:27, from d:\boost/boost/regex/v4/regex.hpp:39, from d:\boost/boost/regex.hpp:31, from test.cpp:4: d:\boost/boost/regex/v4/regex_traits_defaults.hpp: In instantiation of 'const charT* boost::re_detail::get_escape_R_string() [with charT = wchar_t]': d:\boost/boost/regex/v4/basic_regex_parser.hpp:804:54: required from 'bool boost::re_detail::basic_regex_parser<charT, traits>::parse_extended_escape() [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex_parser.hpp:308:36: required from 'bool boost::re_detail::basic_regex_parser<charT, traits>::parse_extended() [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex_parser.hpp:134:10: required from 'void boost::re_detail::basic_regex_parser<charT, traits>::parse(const charT*, const charT*, unsigned int) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex.hpp:215:7: required from 'void boost::re_detail::basic_regex_implementation<charT, traits>::assign(const charT*, const charT*, boost::re_detail::basic_regex_implementation<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::re_detail::basic_regex_implementation<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:661:4: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::do_assign(const charT*, const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:382:33: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::assign(const charT*, const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits> = boost::basic_regex<wchar_t, boost::regex_traits<wchar_t> >; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:367:48: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::assign(const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits> = boost::basic_regex<wchar_t, boost::regex_traits<wchar_t> >; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:336:7: required from 'boost::basic_regex<charT, traits>::basic_regex(const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits>::flag_type = unsigned int]' test.cpp:15:37: required from here d:\boost/boost/regex/v4/regex_traits_defaults.hpp:329:73: warning: narrowing conversion of ''\37777777605'' from 'char' to 'const wchar_t' inside { } [-Wnarrowing] d:\boost/boost/regex/v4/regex_traits_defaults.hpp:331:64: warning: narrowing conversion of ''\37777777605'' from 'char' to 'const wchar_t' inside { } [-Wnarrowing] code : #include <iostream> #include <boost/regex.hpp> int main() { boost::regex narrow_str_regex("a+"); boost::wregex wide_str_regex(L"a+"); } boost: http://sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z compiler: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.... ( and I know that this is the bug: https://svn.boost.org/trac/boost/ticket/7263 ) so, any tricks to get around this (some compiler switches?, I dunno) ? Or can I just ignore this error ? (Yes I need regex matching on wide strings.) -- View this message in context: http://boost.2283326.n4.nabble.com/narrowing-conversion-warning-in-boost-s-r... Sent from the Boost - Users mailing list archive at Nabble.com.
gcc is being used; correct? If the problem is that -Wnarrowing should not be applied globally, then something called a 'pragma' can be used. A 'pragama' will help by telling gcc not to apply a particualar gcc option onto an included header. On the other hand, I would have hacked the BOOST source not knowing that PRAGMA itself could fix the problem. That gets annoying though every time there is a new source tar ball to hack. Also, https://svn.boost.org/trac/boost/newticket can be used to leave bug reports to be read by moderators of the source. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnarrowing " #include <boost/regex.hpp> #pragma GCC diagnostic pop -- Thank you Jason Regards, sadhilab@hypersurf.com
#pragma GCC diagnostic ignored "-Wnarrowing "
Thanks! But that extra space has no place here, it creates another error, I will add for the record in case someone will be searching. <stdin>:13:32: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas] -- View this message in context: http://boost.2283326.n4.nabble.com/narrowing-conversion-warning-in-boost-s-r... Sent from the Boost - Users mailing list archive at Nabble.com.
The first line compiles ok. The second also produces working EXE, but in addition I get this large error:
In file included from d:\boost/boost/regex/v4/regex_traits.hpp:35:0, from d:\boost/boost/regex/regex_traits.hpp:27, from d:\boost/boost/regex/v4/regex.hpp:39, from d:\boost/boost/regex.hpp:31, from test.cpp:4: d:\boost/boost/regex/v4/regex_traits_defaults.hpp: In instantiation of 'const charT* boost::re_detail::get_escape_R_string() [with charT = wchar_t]': d:\boost/boost/regex/v4/basic_regex_parser.hpp:804:54: required from 'bool boost::re_detail::basic_regex_parser<charT, traits>::parse_extended_escape() [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex_parser.hpp:308:36: required from 'bool boost::re_detail::basic_regex_parser<charT, traits>::parse_extended() [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex_parser.hpp:134:10: required from 'void boost::re_detail::basic_regex_parser<charT, traits>::parse(const charT*, const charT*, unsigned int) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>]' d:\boost/boost/regex/v4/basic_regex.hpp:215:7: required from 'void boost::re_detail::basic_regex_implementation<charT, traits>::assign(const charT*, const charT*, boost::re_detail::basic_regex_implementation<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::re_detail::basic_regex_implementation<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:661:4: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::do_assign(const charT*, const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:382:33: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::assign(const charT*, const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits> = boost::basic_regex<wchar_t, boost::regex_traits<wchar_t> >; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:367:48: required from 'boost::basic_regex<charT, traits>& boost::basic_regex<charT, traits>::assign(const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits> = boost::basic_regex<wchar_t, boost::regex_traits<wchar_t> >; boost::basic_regex<charT, traits>::flag_type = unsigned int]' d:\boost/boost/regex/v4/basic_regex.hpp:336:7: required from 'boost::basic_regex<charT, traits>::basic_regex(const charT*, boost::basic_regex<charT, traits>::flag_type) [with charT = wchar_t; traits = boost::regex_traits<wchar_t>; boost::basic_regex<charT, traits>::flag_type = unsigned int]' test.cpp:15:37: required from here d:\boost/boost/regex/v4/regex_traits_defaults.hpp:329:73: warning: narrowing conversion of ''\37777777605'' from 'char' to 'const wchar_t' inside { } [-Wnarrowing] d:\boost/boost/regex/v4/regex_traits_defaults.hpp:331:64: warning: narrowing conversion of ''\37777777605'' from 'char' to 'const wchar_t' inside { } [-Wnarrowing]
( and I know that this is the bug: https://svn.boost.org/trac/boost/ticket/7263 )
Do different issue - that relates to warnings generated by PTHREAD_MUTEX_INITIALIZER over which we have no control.
so, any tricks to get around this (some compiler switches?, I dunno) ? Or can I just ignore this error ? (Yes I need regex matching on wide strings.)
Just committed this patch for this: https://svn.boost.org/trac/boost/changeset/82662 HTH, John.
participants (3)
-
(Jason) SAD * HI * LAB
-
John Maddock
-
rsk82