https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123323
Bug ID: 123323
Summary: -Wpedantic does not warn on usage of __auto_type
extension
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: stuzyf at 163 dot com
Target Milestone: ---
When compiling a C program with the -Wpedantic flag, GCC does not issue a
warning for the usage of the __auto_type keyword, which is a GCC-specific
extension. According to the GCC documentation and the purpose of -Wpedantic,
the compiler should warn about non-standard extensions such as __auto_type.
Here is a minimal example:
int main(){
int a = 3;
__auto_type b = a; // b is inferred as int
return 0;
}
The above code can be tested hereļ¼https://godbolt.org/z/8jPbh9aP9
The GCC documentation explicitly states that -Wpedantic does not cause warning
messages for the use of certain "alternate keywords" whose names begin and end
with __, and expressions following __extension__. These are considered
non-standard extensions typically used in system headers and should be avoided
in application programs.
While this explanation seems to cover a range of GCC-specific extensions, the
__auto_type extension (which is also a GCC extension) is not specifically
mentioned in the documentation. It seems that __auto_type is treated similarly
to other non-standard extensions, but the lack of any warning or error when
-Wpedantic is enabled suggests that GCC may not be enforcing warnings for this
extension, which could be a bug.
This issue contradicts the expected behavior of -Wpedantic, which is supposed
to warn about non-standard extensions and non-conforming code.
Thank you for looking into this, and I appreciate any clarification you could
provide regarding this matter!