Paul Jurczak
Paul Jurczak

Reputation: 8173

Different behavior of <filesystem> in VS2013 vs. VS2012

I'm getting different behavior between VS2012 Update 4 and VS2013 Update 1 in this test program:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <filesystem>

using namespace std;
using namespace std::tr2::sys;

void main()
{
  string s("C:\\");

  for (auto i = directory_iterator(path(s).parent_path()); i != directory_iterator(); ++i) 
    cout << (path(s).parent_path()/i->path()).string() << endl;
}

VS2012 produces:

C:AUTOEXEC.BAT
...

VS2013 produces:

C:C:AUTOEXEC.BAT
...

Which behavior conforms with C++ standard?

EDIT

Since filesystem is not yet in C++ standard, but is only a library proposal, I rephrase my question: is VS2013 behavior a bug?

Upvotes: 1

Views: 1164

Answers (1)

Marius Bancila
Marius Bancila

Reputation: 16338

I believe this was a bug in VC++ 2012. Here's an excerpt from C++11/14 STL Features, Fixes, And Breaking Changes In VS 2013.

<filesystem>'s directory_iterator was returning paths that were too short (DevDiv#411531). (Note that recursive_directory_iterator worked correctly.) We fixed directory_iterator to follow N1975, the Filesystem V2 draft. (Filesystem V3 is on our radar, but it won't be implemented in 2013 RTM.)

You can find N1975 here.

Upvotes: 4

Related Questions