Skip to content

tellg returns -1 when using clang++ to get the size of a large file (around 6GB) on Windows #462

@gevikhn

Description

@gevikhn

When compiling C++ code with clang++ on Windows, the tellg() function returns -1 when attempting to get the size of a large file (around 6GB). However, when compiling the same code with MSVC or g++, the file size is retrieved correctly.

#include <fstream>
#include <iostream>
int main() {
    std::ifstream inFIle("test.file", std::ios::binary|std::ios::in);
    if(!inFIle.is_open() || !inFIle.good()) {
        std::cout << "fail" << std::endl;
        return 0;
    }
    inFIle.seekg(0, std::ios::end);
    auto size = inFIle.tellg();
    inFIle.seekg(0, std::ios::beg);

    std::cout << size << std::endl;

    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions