https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113246

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the exception for a deleted pwd is also correct.

weakly_canonical uses status(".") to check if the current directory exists.
That returns true, even if the directory has been deleted (it still exists
because there are open descriptors referring to it, you just can't find it by
name any longer). Because the directory exists, we call canonical(".") to get
its absolute name. But that fails, because it uses current_path()/p and
absolute_path uses getcwd() which fails with ENOENT.

The directory exists, but you can't get its name, so you can't canonicalize it.

So I think the libstdc++ behaviour conforms to the standard.

I think it might also be conforming if weakly_canonical detected that
exists(".") is insufficient to guarantee that we can call canonical. Since the
point of weakly_canonical is to handle non-existing directories, I think it
would be useful to add a special case for relative paths explicitly beginning
with "." if current_path() fails. But I don't think the standard requires us to
do that.

Reply via email to