News for hackers. Stuff that matters.
Re:C Is Turing Complete by fanf2 on Friday August 02, 2024 @03:55PM (#41142062)
I think in the real world where a file can have a 64 bit size and long is 32 bits, ftell() can work or return an error depending on the size of the file. There isn’t really any other reasonable implementation in that situation.

So ftell() can exist but fail for unbounded seekable streams. The standard does not require ftell() to provide an answer in all situations.

Re:C Is Turing Complete by oecumena on Saturday August 03, 2024 @01:10AM (#41144803)
Still won't work. The Standard explicitly specifies that FILE type includes all stream attributes, including position indicator:

    ISO/IEC 9899:TC3 7.19.1 
    FILE
    which is an object type capable of recording all the information needed to control a
    stream, including its file position indicator, a pointer to its associated buffer (if any), an
    error indicator that records whether a read/write error has occurred, and an end-of-file
    indicator that records whether the end of the file has been reached;

Hence no stream can be longer than 2^(sizeof(FILE)*CHAR_BIT) (6.2.6.1 guarantees that objects of any type cannot have "hidden" bits of state not accounted by sizeof()).