https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108173
Bug ID: 108173 Summary: GCC allows attributes in the wrong locations inside a cast Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(void) { return static_cast<[[]]int>(1); } int g(void) { return static_cast<const [[]] int>(1); } ``` These two casts should be invalid as far as I can tell reading the C++ specifications. The spec has: type-specifier-seq: type-specifier attribute-specifier-seq_opt type-specifier type-specifier-seq Which means the attributes can only happen at the end of the type. I do think we should only have a pedantic warning for this case and allow it as an extension.