[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))

2023-04-24 Thread rusty at rustcorp dot com.au via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

--- Comment #47 from rusty at rustcorp dot com.au ---
Civility please.

We're all trying to find a path to improve things here.  But accept that the
conversation on this issue is only a weak indication of consensus.

As Andrew Pinski says "people are mis-using this attribute", and Jakub Jelinek
makes a similar point.  The use of _wur has changed from "ignoring the result
is criminally wrong" to "possibly wrong".

I still put a comment complaining about this every time I hit it, which is
about once or twice a year.  But I have little more to say; it's been almost 20
year after all :)

[Bug c/106424] New: __attribute__ unused confuses -Wshadow when placed on internal parameter of fn ptr

2022-07-24 Thread rusty at rustcorp dot com.au via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106424

Bug ID: 106424
   Summary: __attribute__ unused confuses -Wshadow when placed on
internal parameter of fn ptr
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rusty at rustcorp dot com.au
  Target Milestone: ---

OK, this is a weird one.  I have some automated code which adds attributes
and it (overzealously) added it to the internal parameter of a callback:



void func(char *arg,
  void (*cb)(char *arg __attribute__((__unused__
{ }


With -Wshadow=local (and -Wshadow) this gives a spurious warning:


foo.c:2:28: warning: declaration of ‘arg’ shadows a parameter [-Wshadow]
2 |   void (*cb)(char *arg __attribute__((__unused__
  |  ~~^~~
foo.c:1:17: note: shadowed declaration is here
1 | void func(char *arg,
  |   ~~^~~