Opened 17 years ago
Closed 15 years ago
#471 closed Bugs (wontfix)
boost.range and "const char[]".
Reported by: | sergey_shandar | Owned by: | Thorsten Ottosen |
---|---|---|---|
Milestone: | Component: | range | |
Version: | Boost 1.34.0 | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
// Both boost::end(...) and boost::size(...) return wrong values. // Compilers: GCC 3.3.4 and VC 7.1. // A simple example: #include <boost/range/size.hpp> #include <boost/test/minimal.hpp> int test_main(int, char *[]) { const char A[] = "\0A"; BOOST_CHECK(boost::size(A)==2); // failed. return 0; }
Change History (10)
comment:2 by , 17 years ago
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.
comment:3 by , 17 years ago
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
comment:4 by , 17 years ago
Status: | assigned → closed |
---|
Logged In: YES user_id=957289 >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.
comment:5 by , 16 years ago
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
comment:6 by , 16 years ago
Logged In: YES user_id=957289 >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. >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(&)[N] types are accepteble.
comment:8 by , 15 years ago
Component: | None → range |
---|---|
Description: | modified (diff) |
Severity: | → Problem |
Status: | assigned → new |
comment:10 by , 15 years ago
Resolution: | Rejected → wontfix |
---|---|
Status: | new → closed |
For 1.35 I have added this test:
const char A[] = "\0A"; BOOST_CHECK_EQUAL( boost::size(A), 3u );
This is the bahavior of 1.35.
Note:
See TracTickets
for help on using tickets.