Boost C++ Libraries: Ticket #515: VC7.1 boost_1_33_0 regex runtime assertion fail. https://svn.boost.org/trac10/ticket/515 <pre class="wiki">Hi, I am new in boost. I use boost_1_33_0 and VC7.1. When I run the regex sample code(string split and credit card number check), assertion failed. I dont know how to solve it. I build and install boost like this: bjam "-sTOOLS=vc-7_1" install Then I set the include path and library path in VC7.1. I can compile and build(debug mode) the program successfully, but fail to execute it. The assertion fail message is as following: Assertion failed: r == 1 &lt;&lt; 8, file C:\boost_1_33_0\libs\regex\build\../src/w32_ regex_traits.cpp, line 108 ------ Then I tried using another boost library "tokenizer". It works good. I think I install boost properly. I just can't figure out why I can't use regex. My VC7.1 environment settings are all default. I tried another VC6-built boost, and it has the same assertion fail with my VC6. Can anyone help me with this? Thank you. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/515 Trac 1.4.3 mindaou Thu, 17 Nov 2005 07:25:14 GMT summary changed https://svn.boost.org/trac10/ticket/515#comment:1 https://svn.boost.org/trac10/ticket/515#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">boost_1_33_0 regex runtime assertion fail.</span> → <span class="trac-field-new">VC7.1 boost_1_33_0 regex runtime assertion fail.</span> </li> </ul> Ticket John Maddock Thu, 17 Nov 2005 10:27:49 GMT <link>https://svn.boost.org/trac10/ticket/515#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/515#comment:2</guid> <description> <pre class="wiki">Logged In: YES user_id=14804 The assertion will fail if the windows API LCMapString has failed for some reason. This code is heavily tested on this platform and I've never seen this before, so I'm assuming that there is something about your machine or locale that's causing the problem. So... can you please tell me which version of Windows you are running and which locale the machine is using? Can you also insert a call to GetLastError just before the assertion that fails (after the call to LCMapString) so we can find out why the failure is occuring? Many thanks, John Maddock. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>mindaou</dc:creator> <pubDate>Fri, 18 Nov 2005 00:00:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/515#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/515#comment:3</guid> <description> <pre class="wiki">Logged In: YES user_id=1380717 Thanks for your response. I use Windows XP HOME SP2 Traditional Chinese Version. I printed the locale in the program: cout.getloc().name() It shows "C". I made the following testing: I used another machinese (Windows 2003 Enterprise English ver.) to run my executable file. Surprisingly, it works! Therefore, I think it's the locale problem you mentioned. In my computer, the "Control Panel/Regional and Language Options/Regional Options/Standards and formats" is [CHINESE(TAIWAN)]. In that Windows 2003 machine it's [ENGLISH(U.S.)]. So, I changed my computer setting to [ENGLISH(U.S.)], and then, the program works on machine without any assertion failure! With CHINESE setting, it assertion fails. With ENGLISH setting, it works. This is my current status. Besides, I inserted GetLastError() in your code. Like this: -------------------------------------- int r = ::LCMapStringA(this-&gt;m_locale, LCMAP_LOWERCASE, char_map, 1 &lt;&lt; CHAR_BIT, this-&gt;m_lower_map, 1 &lt;&lt; CHAR_BIT); std::cout&lt;&lt;GetLastError()&lt;&lt;" "&lt;&lt;r; BOOST_ASSERT(r == 1 &lt;&lt; CHAR_BIT); -------------------------------------- When assertion fails, GetLastError()=122, r=240 When NO assertion fails, GetLastError()=122, r=256 Hope these information help. mindaou </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sun, 20 Nov 2005 10:46:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/515#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/515#comment:4</guid> <description> <pre class="wiki">Logged In: YES user_id=14804 Thanks for the information, can you change the final block of code to read as shown below and see if that fixes the problem? If posible please run the regression tests by doing a: cd libs/regex/test bjam -sTOOLS=vc-7_1 test Many thanks, John Maddock. And the code: // // fill in lower case map: // char char_map[1 &lt;&lt; CHAR_BIT]; for(int ii = 0; ii &lt; (1 &lt;&lt; CHAR_BIT); ++ii) char_map[ii] = static_cast&lt;char&gt;(ii); int r = ::LCMapStringA(this-&gt;m_locale, LCMAP_LOWERCASE, char_map, 1 &lt;&lt; CHAR_BIT, this-&gt;m_lower_map, 1 &lt;&lt; CHAR_BIT); BOOST_ASSERT(r != 0); if(r &lt; (1 &lt;&lt; CHAR_BIT)) { // if we have multibyte characters then not all may have been given // a lower case mapping: for(int jj = r; jj &lt; (1 &lt;&lt; CHAR_BIT); ++jj) this-&gt;m_lower_map[jj] = static_cast&lt;char&gt;(jj); } r = ::GetStringTypeExA(this-&gt;m_locale, CT_CTYPE1, char_map, 1 &lt;&lt; CHAR_BIT, this-&gt;m_type_map); BOOST_ASSERT(0 != r); </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>mindaou</dc:creator> <pubDate>Tue, 22 Nov 2005 06:48:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/515#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/515#comment:5</guid> <description> <pre class="wiki">Logged In: YES user_id=1380717 fixed! Good work~ Could you please explain what's the bug is? mindaou </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Wed, 23 Nov 2005 10:54:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/515#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/515#comment:6</guid> <description> <pre class="wiki">Logged In: YES user_id=14804 Not completely: My assumption was that LCMapString would either fail completely (return 0) or provide lower case mapping for all the characters requested. Apparently it can succeed by just providing *some* of the information requested. My guess is that upper/lower case mappings have no meaning for characters above a certain value when using a multibyte character set, so the fix is to set the identity translation for all the characters that don't get translated by LCMapString. One caveat: using a narrow character regular expression on a multibyte character string is not actually a good idea, unless you restrict yourself to ASCII characters, Boost.Regex is *not* multibyte aware, no regex engines are that I'm aware of. If you really need that level of internationalisation suppport then either use wide character regexes or the new Unicode regexes (which support things like UTF-8 if you need it). BTW this fix may be too late for the 1.33.1 relese, but I'll ask. John. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Wed, 23 Nov 2005 10:54:36 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/515#comment:7 https://svn.boost.org/trac10/ticket/515#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket