[Bug c++/91947] New: std::filesystem::file_size will return wrong value on 32bit platforms with large files support

2019-10-01 Thread fregloin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91947

Bug ID: 91947
   Summary: std::filesystem::file_size will return wrong value on
32bit platforms with large files support
   Product: gcc
   Version: 8.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: fregloin at gmail dot com
  Target Milestone: ---

std::filesystem::file_size will return wrong value on 32bit platforms with
large files support

/trunk/libstdc++-v3/src/filesystem/ops.cc
/trunk/libstdc++-v3/src/filesystem/std-ops.cc (the same problem)

struct S field `size` of type `size_t`.

When it casted from uintmax_t to size_t on 32bit platform, the result of this
function will be wrong.

fs::file_size(const path& p, error_code& ec) noexcept
{
  struct S
  {
S(const stat_type& st) : type(make_file_type(st)), size(st.st_size) { }
  }
S() : type(file_type::not_found) { }
file_type type;
size_t size;
...
};

stat.off_t type is off64_t when large file support is enabled.

[Bug libstdc++/91947] std::filesystem::file_size will return wrong value on 32bit platforms with large files support

2019-10-02 Thread fregloin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91947

--- Comment #3 from Fregl  ---
In out product we use 32 bit toolchain, but work with large files.
So there is only solution to use direct stat call insted fs::file_size?
It seems this is firm limitation.