Boost C++ Libraries: Ticket #471: boost.range and "const char[]". https://svn.boost.org/trac10/ticket/471 <pre class="wiki">// Both boost::end(...) and boost::size(...) return wrong values. // Compilers: GCC 3.3.4 and VC 7.1. // A simple example: #include &lt;boost/range/size.hpp&gt; #include &lt;boost/test/minimal.hpp&gt; int test_main(int, char *[]) { const char A[] = "\0A"; BOOST_CHECK(boost::size(A)==2); // failed. return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/471 Trac 1.4.3 nobody Fri, 26 Aug 2005 05:20:57 GMT <link>https://svn.boost.org/trac10/ticket/471#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:1</guid> <description> <pre class="wiki">Logged In: NO The size is supposed to be 3 in this example. As described in the C++ standard, C-style strings include a terminating "\0" character. Your string will have 3 characters, '\0', 'A', and '\0'. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>sergey_shandar</dc:creator> <pubDate>Fri, 26 Aug 2005 07:23:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/471#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:2</guid> <description> <pre class="wiki">Logged In: YES user_id=957289 I know that a size of this array is 3. boost::size(A) should return 2 because of http://www.boost.org/libs/range/doc/boost_range.html#size. But it returns 0. The problem is boost::size and boost::end handles A as "const char *" instead of "const char[3]". I have not checked other functions as rbegin. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Thorsten Ottosen</dc:creator> <pubDate>Fri, 07 Oct 2005 01:05:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/471#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:3</guid> <description> <pre class="wiki">Logged In: YES user_id=637229 The support for string arguments is deprecated and will go away in the next major release. According to the current implementation, the code behaves just as designed. br Thorsten </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>sergey_shandar</dc:creator> <pubDate>Tue, 25 Oct 2005 07:41:47 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/471#comment:4 https://svn.boost.org/trac10/ticket/471#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=957289 &gt;According to the current implementation, the code behaves just as designed. No, it doesn't. Accordint to the documentation http://www.boost.org/libs/range/doc/boost_range.html#size it MUST return 2 but it returns 0. It's a serious bug. Change either documentation or code. </pre> Ticket Thorsten Ottosen Mon, 23 Oct 2006 13:42:25 GMT <link>https://svn.boost.org/trac10/ticket/471#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:5</guid> <description> <pre class="wiki">Logged In: YES user_id=637229 arrays (and so string literals) have their size deduced at compile-time. Embedding a null will not change that. What is the use of the literal above anyway? -Thorsten </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>sergey_shandar</dc:creator> <pubDate>Mon, 23 Oct 2006 14:07:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/471#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:6</guid> <description> <pre class="wiki">Logged In: YES user_id=957289 &gt;arrays (and so string literals) have their size deduced at compile-time. Embedding a null will not change that. Yeah, it would be good if it beahaves like this. However, according to example, the size depends on a position of a null so boost::size(A) == 0 (Boost 1.33). Sure I expected compile time - 2. &gt;What is the use of the literal above anyway? It's just a minimal example that shows a bug in Boost.Range 1.33, I don't know much about 1.34. I prefer compile time computation where it's possible. Currently, I use my own range library (http://cbear.berlios.de/range), it doesn't accept char* and wchar_t* as a range. Only T(&amp;)[N] types are accepteble. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 05 Jun 2007 02:30:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/471#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:7</guid> <description> <p> The same bug in 1.34 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Tue, 21 Aug 2007 21:06:49 GMT</pubDate> <title>status, component, description changed; severity set https://svn.boost.org/trac10/ticket/471#comment:8 https://svn.boost.org/trac10/ticket/471#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">range</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/471?action=diff&amp;version=8">diff</a>) </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket anonymous Thu, 06 Sep 2007 06:39:45 GMT <link>https://svn.boost.org/trac10/ticket/471#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/471#comment:9</guid> <description> <p> 1.34.1 has the same bug. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Thorsten Ottosen</dc:creator> <pubDate>Tue, 23 Oct 2007 18:45:20 GMT</pubDate> <title>status, resolution changed https://svn.boost.org/trac10/ticket/471#comment:10 https://svn.boost.org/trac10/ticket/471#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">Rejected</span> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> For 1.35 I have added this test: </p> <blockquote> <p> const char A[] = "\0A"; BOOST_CHECK_EQUAL( boost::size(A), 3u ); </p> </blockquote> <p> This is the bahavior of 1.35. </p> Ticket