[Bug c/82909] Scope of type defined by offsetof() macro
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 8 23:55:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82909
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 8 Nov 2017, tydeman at tybor dot com wrote:
> /*
> * C standard appears to be unclear on scope of new type defined in
> * offsetof() macro. Some compilers accept; some reject.
> * This is related to C Defect Report 496.
> */
>
> #include <stddef.h> /* offsetof() */
>
> int main(void){
>
> if( 0 == (int)offsetof( struct s4 {int i4;}, i4 ) ){
> struct s4 s43; /* OK here */
> }
> {
> struct s4 s44; /* Should(?) be OK here */
> }
This is accepted for -std=c89 (where selection statements don't introduce
block scopes) and rejected for -std=c99 and -std=c11 (where selection
statements do introduce block scopes; C11 6.8.4p3). I don't see a bug
here; what do you think should behave differently?
More information about the Gcc-bugs
mailing list