[Bug c/107947] New: __has_c_attribute incorrectly identifies attribute as supported

xen0n at gentoo dot org gcc-bugzilla@gcc.gnu.org
Thu Dec 1 13:43:45 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107947

            Bug ID: 107947
           Summary: __has_c_attribute incorrectly identifies attribute as
                    supported
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xen0n at gentoo dot org
  Target Milestone: ---

Created attachment 53999
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53999&action=edit
minimal reproducing example

The gcc trunk incorrectly indicates that the [[noreturn]] spelling of the
noreturn attribute works on -std=gnu99 with the attached source:

> $ ./gcc/xgcc -B./gcc -E -P -std=gnu99 ../x.h
> C standard version is 199901L, has "__has_c_attribute"
> "__has_c_attribute(noreturn)" = 202202

This is commit abf05583dbc86a6667b63f5bda6ba57fe55a1b25, while:

> $ gcc-12.1.1 -E -P -std=gnu99 x.h
> C standard version is 199901L, has "__has_c_attribute"
> "__has_c_attribute(noreturn)" = 0

and:

> $ clang-15 -E -P -std=gnu99 x.h
> 
> C standard version is 199901L, has "__has_c_attribute"
> "__has_c_attribute(noreturn)" = 0

I haven't bisected yet but can help doing so if necessary. One of the affected
code in the wild is the fresh tzdb-2022g from https://www.iana.org/time-zones.


More information about the Gcc-bugs mailing list