Repository navigation
__builtin_offsetof is not entered in strict mode, so offsetof from gcc's <stddef.h> fails under -A
#185
thinkoid
started this conversation in
Issue Triage - Standard Conformance
Replies: 2 comments
|
A correction to the report. cpfe compiles C++ unless given a C option; the The C runs give the same three errors:
The issue therefore covers C89, C99 and C++03 strict modes. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
src/fe_init.centers the__builtin_offsetofkeyword only in GNU 4.0+, Microsoft 1910+ or clang emulation. On Linux, glibc ships no<stddef.h>; the freestanding headers come from gcc, and gcc's<stddef.h>unconditionally definesoffsetofas__builtin_offsetof. In strict mode (-A), where GNU emulation is excluded, every use ofoffsetoftherefore fails.Strict mode can provide
__builtin_offsetofwithout giving up conformance. The name is reserved to the implementation (C17 7.1.3p1; C++03 17.4.3.1.2p1), so no strictly conforming program can use it, and an extension no such program can reach is permitted (C17 4p6; C++03 1.4p8). A program that usesoffsetofuses only the standard macro; the reserved name appears in the implementation's own header. Strict mode already enters three names of this kind in every mode:__ALIGNOF__,__alignof__and__INTADDR__(fe_init.c:1079-1081).Observed Behavior
cpfe built from the
linux-gcc-releasepreset, run with the repository's own base. A strictly conforming program that usesoffsetof, with gcc's include directory and/usr/includeas the system include directories:cpfe --c++03 -Awith the same options gives the same three errors.The cause, reduced to the keyword. This program is not strictly conforming; it only shows that
__builtin_offsetofis missing under-Aand present under--g++:Expected Behavior
__builtin_offsetofis available under-A, sooffsetoffrom gcc's<stddef.h>works there, as a constant expression. Entering the keyword wherever__INTADDR__is entered would do it.A workaround that works today:
Additional Details
ca5890bab8, x86_64 Linux.Configuration:
cpfe --dump_configurationoutput attached (dump_configuration.txt).All reactions