Bug 15766 - C++ ABI inconsistency for fpos_t on 64-bit archs
Summary: C++ ABI inconsistency for fpos_t on 64-bit archs
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
: 15767 (view as bug list)
Depends on:
Reported: 2013-07-21 19:19 UTC by Rich Felker
Modified: 2019-01-07 18:28 UTC (History)
2 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Rich Felker 2013-07-21 19:19:07 UTC
On 64-bit archs, -D_FILE_OFFSET_BITS=64 should not affect the C++ ABI (name mangling). Regardless of whether there's an official policy to this effect, it makes sense, since some applications will always compile with -D_FILE_OFFSET_BITS=64 and others will attempt to detect whether they need it before adding it.

For most types that change definition according to _FILE_OFFSET_BITS, there is an underlying type name independent of the typedef name, and no issue arises. However, fpos_t is defined to a structure with no tag, and thus the original typedef name of either _G_fpos_t or _G_fpos64_t gets used in name mangling. Thus if a C++ library uses fpos_t as part of its public interface, and the library and application are compiled with different values of _FILE_OFFSET_BITS, the ABI will gratuitously mismatch. On 32-bit archs it should be expected to mismatch, and the library would have a policy that you have to build with 64-bit off_t. But on 64-bit archs, it should not matter whether _FILE_OFFSET_BITS was defined. This issue would be even more of a problem if multiple libraries disagreed on whether it was supposed to be set, and an application needed to use both libraries.

With that said, I'm not sure why features.h doesn't make _FILE_OFFSET_BITS a complete no-op on 64-bit archs. That would make the issue go away entirely.
Comment 1 Andreas Schwab 2013-07-21 20:32:56 UTC
*** Bug 15767 has been marked as a duplicate of this bug. ***