https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113246
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Davide Pesavento from comment #0) > note that canonical("") currently throws a filesystem_error) That's clearly correct, as canonical says that !exists(p) is an error. > If there are no leading elements of p that exist, should canonical() be > called with an empty path? or should it not be called at all? It makes no sense for weakly_canonical to ever call canonical with an empty path, since that would always report an error (i.e. throw or set ec and return an empty path). That would make it completely useless for paths with no prefix that already exists. So if there are no leading elements of p that exist, then obviously canonical should not be called. The alternative makes no sense. So the behaviour of weakly_canonical seems correct to me. If any leading elements exist, then canonical is called on them, which returns an absolute path, and then the non-existing elements are appended to that. If there are no existing elements, then you get a relative path.