From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC5F23858401; Fri, 19 Jan 2024 08:18:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC5F23858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705652299; bh=LI00S4w4+fqDvLJOtvhAR7NK+EsqZxPNrIVGAmrcblI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dqMAJxsECQ+gUfrqYWaPUH8blhQkr7wSYjG7qIzbdg4u2wtBORq83jzNA5ZlN7cZW xoHT07WZ854JxibFMk6p7U5vvrAzDi7VG5ka9H7xI91eGY+LPbzghmT2KnqGMFWuRL H5RqbYY6uUnH/FdCSBm+zkLAX+/H1uei2qs7LPoM= From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64064] basic_filebuf seekoff return value is unusable for files opened in text mode on Windows Date: Fri, 19 Jan 2024 08:18:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lh_mouse at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64064 --- Comment #2 from LIU Hao --- It looks that MS STL calls `_fseeki64(fp, ...)` [1], while libstdc++ calls `lseek(_fileno(fp), ...)` [2]. The seek operation shall take the buffering of `FILE` struct into account, hence I think the libstdc++ implementation is incorrect. [1] https://github.com/microsoft/STL/blob/442029c6fa37f1b6f9203357de09672d57040= 77c/stl/inc/__msvc_filebuf.hpp#L624 [2] https://github.com/gcc-mirror/gcc/blob/9693459e030977d6e906ea7eb587ed09ee4f= ddbd/libstdc%2B%2B-v3/config/io/basic_file_stdio.cc#L425=