https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81824
Bug ID: 81824 Summary: Warn for missing attributes with function aliases Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jsm28 at gcc dot gnu.org Target Milestone: --- Consider code like the following: void foo (void) __attribute__ ((nothrow)); void __foo (void); void __foo (void) { } void foo (void) __attribute__ ((weak, alias ("__foo"))); Here, the properties of the nothrow attribute are true for __foo as well as foo, but code calling __foo (seeing the declarations, not the definition) won't benefit from the attribute. This is typical of code in glibc: the public header declares foo with some attributes, the internal header may or may not have those attributes on the internal version (even if it uses typeof when declaring the internal function to avoid duplicating the type, that doesn't replicate function attributes), calls to the internal version don't benefit from the attributes if missing from the declaration. When compiling the file with the implementation, it's possible to see that the two functions are the same, and so that the attributes are missing from one declaration. It would be useful to have a warning for this case. Note: this warning is only for attributes relating to the function itself, not to those relating to a particular name for the function. For example, weak, alias, visibility attributes are expected to differ between different names and shouldn't be diagnosed. It would be necessary to work out which existing function attributes fall in which category. Note: some relevant attributes may actually apply to the function's type not the function itself; it's still useful to diagnose when they are missing on one of the aliased functions. Note: I don't know how many false positives this warning might have in glibc, and so whether it would be possible to enable it for all glibc builds or only for a manual review of code in glibc to try to reduce the number of such cases of missing attributes.