On 22.09.2010 20:36, Will Watts wrote:
In article
, Timothy Madden wrote: I do not know about the Filesystem maintainer, but we need a minimal example to reproduce the problem to make our case elsewhere, that is on the bug tracker or on another list.
How about this?
void main() { const char * f = "foo"; char b[5]; strcpy(b, f); fs::path p1(b); // Debugger shows p1.m_pathname.size = 4 after this fs::path p2(f); // But p2.m_pathname.size = 3 cout<< p1<< endl; // prints "foo " cout<< p2<< endl; // prints "foo" cout<< (p1 == p2)<< endl; // prints 1 - they are supposedly identical }
Please can you check that I haven't cocked up the strcpy(), or something idiotic! By all means repeat the exercise with wide characters.
This doesn't show a spectacular crash, but I think it shows that something is amiss with the C array handling - something to do with the terminating zero byte? What do you reckon?
I think that somehow the template constructor for paths takes the entire array passed as argument and not just the null-terminated string inside the array, which may be smaller. I also got a crash with the attached code on Visual Studio 2008. I have created a track ticket https://svn.boost.org/trac/boost/ticket/4677, lets hope someone picks it up. Timothy Madden