https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79008
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed|2017-08-22 00:00:00 |2017-11-24 Ever confirmed|0 |1 --- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #2) > I think what I had in mind was incompatible attribute specifications rather > than missing ones but my description sounds a little confused. > -Wbuiltin-declaration-mismatch also doesn't diagnose incompatible attributes > (maybe it should). > > One example of an incompatibility is the following declaration: > > int __attribute__ ((pure)) abs (int); > > where abs() the built-in is actually declared const. GCC doesn't currently > diagnose this except with my patch for bug 81544 (yet to be reviewed). > > Another, slightly different, example is declaring a standard library > function with the wrong attributes, like this one: > > void* __attribute__ ((malloc, alloc_size (1))) realloc (void*, size_t); > > This is wrong on two counts: first, realloc cannot be declared with > attribute malloc because it need not return a unique pointer. Second, > alloc_size specifies the wrong argument (this is bug 78667). > > Since many built-in functions are decorated with multiple attributes it > seems that rather than pointing out these kinds of issues one attribute at a > time (either when there are more than one or as the user adjusts their > declaration) it would be simpler and more user-friendly to include in the > diagnostic all the attributes the built-in is decorated with. Hence the > suggestion to introduce a a new flag (and perhaps also a conversion > specifier) to the pretty printer to have it (optionally) print the whole > attribute list, or parts of it. > > E.g., > > warning ("%#qD conflicts with built-in declaration %#qD", user_decl, > builtin_in_decl); > > might print > > warning: ‘int abs(int) __attribute__ ((pure))’ conflicts with built-in > declaration ‘int abs(int) __attribute__ ((const))’ Confirmed.