This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/6660: Typedeffed unnamed structs/unions do not compile with gcc-3.1



>Number:         6660
>Category:       c
>Synopsis:       Typedeffed unnamed structs/unions do not compile with gcc-3.1
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue May 14 18:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Anton Altaparmakov
>Release:        gcc 3.1
>Organization:
>Environment:
Linux, compiling Linux kernel 2.5.15 (same applies since kernel version 2.5.11)
>Description:
This is regarding gcc-3.1: Sorry can't give more details about the gcc version but several users of gcc-3.1 have now complained to us that they cannot compile 2.5.12 and above kernels with gcc-3.1 because of this. (2.5.12 is when the new ntfs driver was introduced which uses the unnamed structs/unions.)

gcc-3.1 gives the error: unnamed fields of type other than struct or union are not allowed

However the unnamed field is a typedeffed unnamed struct/union (we have both in the code).

e.g. the first error during kernel 2.5.15 compilation hits fs/ntfs/aops.c in the include file fs/ntfs/layout.h:

gcc -D__KERNEL__ -I/usr/src/linux-2.5.15/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686  -DNTFS_VERSION=\"2.0.6\" -DDEBUG -DKBUILD_BASENAME=aops  -c -o aops.o aops.c
In file included from attrib.h:31,
                 from debug.h:31,
                 from ntfs.h:43,
                 from aops.c:30:
layout.h:299: unnamed fields of type other than struct or union are not allowed

What it is complaining about is this code in layout.h:

typedef struct {
        NTFS_RECORD_TYPES magic; // this is an enumeration
        u16 usa_ofs;
        u16 usa_count;
} __attribute__ ((__packed__)) NTFS_RECORD;

typedef struct {
        NTFS_RECORD;  // this is line 299 on which gcc barfs
        blah...
} __attribute__ ((__packed__)) MFT_RECORD;

Clearly this code is just fine and it used to work with gcc-2.96 and gcc-3.0.x.

I believe this is a bug in gcc-3.1 causing it to not understand that NTFS_RECORD is actually a struct/union, just a typedeffed one but all the same. Having to keep typing "struct NTFS_RECORD" is silly hence why I typedef everything.

If this is not a bug but a feature than I would kindly request that you remove that feature and restore the old behaviour present in gcc-2.96 and gcc-3.0.x...

(Yes I know gcc-2.96 is not an official gcc release, so no need to rant about that.)

I would appreciate your comments on this...

Best regards,

       Anton
-- 
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS Maintainer / IRC: #ntfs on irc.openprojects.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]