Boost logo

Boost :

Subject: [boost] [filesystem.v3] possible bug in replace_extension
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2012-02-07 06:52:08

replace_extension seems to have the wrong behaviour if the provided
new extension does not start with a dot.
The following program:

#include <iostream>
#include <boost/filesystem.hpp>

int main() {
        boost::filesystem::path p("");
        return 0;

built with the following command line on linux 64 (with boost 1.48.0):
-L/soft/bal/usr/gcc-release/boost/lib -lboost_filesystem

produces the following output:

but should produce:

as read from the documentation
path& replace_extension(const path& new_extension = path());
Postcondition: extension() == replacement, where replacement is
new_extension if new_extension.empty() || new_extension[0] == the dot
character, otherwise replacement is the dot character followed by

Adding the dot before foo makes the program work: p.replace_extension(".foo");

This seemed to work with filesystem v2.

Frédéric Bron

Boost list run by bdawes at, gregod at, cpdaniel at, john at