Boost C++ Libraries: Ticket #4823: tellg () function of ifstream object is returning -1 for /proc virtual file system files. https://svn.boost.org/trac10/ticket/4823 <p> The tellg function of ifstream object is returning -1 when the position of file pointer is queried for /proc virtual file system files. Below is the example program to demonstrate the problem </p> <p> #include &lt;iostream #include &lt;fstream&gt; using namespace std; </p> <p> int main( int argc, char* argv[] ){ </p> <blockquote> <p> long begin,end; ifstream myfile (argv<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>); begin = myfile.tellg(); cout &lt;&lt; " begin " &lt;&lt; begin &lt;&lt; endl; myfile.seekg (0, ios::end); end = myfile.tellg(); myfile.close(); cout &lt;&lt; "size is: " &lt;&lt; (end-begin) &lt;&lt; " bytes.\n"; return 0; </p> </blockquote> <p> } </p> <p> pmanth2@cyder:~$ ./fstream partA.cpp ( Normal text file ) </p> <blockquote> <p> begin 0 </p> </blockquote> <p> size is: 6692 bytes. </p> <p> pmanth2@cyder:~$ ./fstream /proc/cpuinfo ( virtual file system file ) </p> <blockquote> <p> begin 0 </p> </blockquote> <p> size is: -1 bytes. </p> <p> The tellg() should return the file pointer location for /proc file system files also. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4823 Trac 1.4.3 Beman Dawes Sat, 04 Dec 2010 13:05:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4823#comment:1 https://svn.boost.org/trac10/ticket/4823#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> This query is about how standard library &lt;fstream&gt; works; it has nothing to do with any Boost libraries. Thus I'm closing it as "invalid". </p> <p> To find out why your code works the way it does, you might want to look at your operating systems's documentation of how virtual files are reported via the applications program interface (API). </p> <p> HTH, </p> <p> --Beman </p> Ticket