Bug 767538
Summary: | Compilation error when defining the same type twice with typedef | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Christophe Fergeau <cfergeau> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | qe-baseos-tools-bugs |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.2 | CC: | dodji, dodji |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2011-12-14 13:28:18 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Christophe Fergeau
2011-12-14 10:31:59 UTC
The duplicate typedefs are invalid in both ISO C89 and C99, it is only valid in the upcoming C1X standard that is being worked on. GCC 4.6 and later allow it as an extension (except for -pedantic-errors) in preparation for C1X standard, but that doesn't change anything on it being invalid in C89 and C99, so I'm against backporting those changes to GCC 4.4 or earlier. Just fix up your sources. Oh ok, I assumed that this was valid C since gcc 4.6 accepted it, didn't think of the various revisions of the standard. Thanks a lot for the input, next time I'll do more homework before opening a bug. The C specification is a source of never-ending learning to me. :-) So it looks like the part of the C99 specification that forbids re-declarations of typedefs is 6.7/3: "If an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space, except for tags as specified in 6.7.2.3." And typedef names are not tags. Later, in C1X, it was decided to allow the redeclaration of typedefs of the same type in the same tag, as C++ allows: http://www.velocityreviews.com/forums/t674488-benign-typedef-definition.html. |