[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #8 from Manuel López-Ibáñez --- (In reply to Peter Eisentraut from comment #2) > No, these "functions" need to have a usable return value, because someone > could write > > if (!sigemptyset(...)) > weirderror(); Note that just using: (void) sigemptyset(); silences the warning in those cases where you want to ignore the return value, which could be useful while someone comes up with a patch for a more permanent fix. Or you can use -Wno-unused-value for now.
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #7 from Marek Polacek --- Can we settle on just disabling the warning for system headers? Those are kind of out of control, but otherwise if you really want it, use ({ }) or make it a static inline function (as glibc/kernel). For static inlines there is no performance penalty. Note that the C++ FE has this warning for much more longer than the C FE, completely removing it doesn't seem desirable to me.
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #6 from Peter Eisentraut --- This particular case is in system headers, but there are other cases that are not, so this isn't going to help in general. I think this is a legitimate way to write a function-like macro that has a side-effect and a return value, and the warning is bogus.
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 Manuel López-Ibáñez changed: What|Removed |Added CC||manu at gcc dot gnu.org --- Comment #5 from Manuel López-Ibáñez --- Apple should mark their system headers as such using: #pragma GCC system_header Other compilers will ignore this pragma. You could do that simply by adding a dummy header that includes the real header. Or you can just disable the warning in your code with #pragma GCC diagnostic ignore "Wwhatever". We could also not warn if the right-hand operand comes from the macro definition, but I am not sure how difficult is to do that and whether it is really worth the effort.
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #4 from Peter Eisentraut --- Not really, because this code is in header files not under my control, and those header files should presumably work with a variety of C compilers and shouldn't need to rely on GCC extensions.
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #3 from Marek Polacek --- On Tue, May 06, 2014 at 06:33:03PM +, peter_e at gmx dot net wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 > > --- Comment #2 from Peter Eisentraut --- > No, these "functions" need to have a usable return value, because someone > could > write > > if (!sigemptyset(...)) > weirderror(); So would the following work for you? #define sigemptyset(set) (__extension__ ({ *(set) = 0; 0; }))
Re: [Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
On Tue, May 06, 2014 at 06:33:03PM +, peter_e at gmx dot net wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 > > --- Comment #2 from Peter Eisentraut --- > No, these "functions" need to have a usable return value, because someone > could > write > > if (!sigemptyset(...)) > weirderror(); So would the following work for you? #define sigemptyset(set) (__extension__ ({ *(set) = 0; 0; }))
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 --- Comment #2 from Peter Eisentraut --- No, these "functions" need to have a usable return value, because someone could write if (!sigemptyset(...)) weirderror();
[Bug c/61081] excessive warnings: right-hand operand of comma expression has no effect
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61081 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #1 from Marek Polacek --- Can't you just cast the RHS to void?