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

            Bug ID: 113663
           Summary: [MinGW] std::filesystem::hard_link_count always
                    returns 1
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lennoxhoe at gmail dot com
  Target Milestone: ---

Hello!

std::filesystem::hard_link_count() appears to always return 1 when built with
gcc-13.2.0 + mingw-w64ucrt-11.0.1-r3 on Windows 10 19045

Stepping through with a debugger, it looks like hard_link_count() queries
Windows'  _wstat64() for this information.

The MSFT documentation claims this is the expected behaviour for non-NTFS
volumes
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/14h5k7ff(v=vs.120)

However, in my tests both the links are located on the same NTFS volume.
Furthermore, GetFileInformationByHandle does return the correct result of 2.

There appears to be some precedence in calling GetFileInformationByHandle as
seen in std::filesystem::equivalent.
Can hard_link_count() receive the same treatment?

Thanks

Reply via email to