[cairo-bugs] [Bug 58727] warn_unused_result noise

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue May 6 11:34:55 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=58727

--- Comment #3 from Bill Spitzak <spitzak at gmail.com> ---
Oh god those gnu-idiots!

I tried it and in fact the multi-line workaround is the only thing that 
works. Or a wrapper function. Compile the following with -Wall:

int fn () __attribute__ ((warn_unused_result));

int used(int i) { return i; }

int main(int argc, const char** argv)
{
   int a, b;
   fn(); /* produces error! */
   (void)fn(); /* produces error! This used to work!*/
   a = fn(); /* produces warning that a is unused */
   b = fn(); (void)b; /* this works */
   used(fn()); /* this also works */
   return 0;
}


On 05/06/2014 07:20 AM, bugzilla-daemon at freedesktop.org wrote:
> *Comment # 2 <https://bugs.freedesktop.org/show_bug.cgi?id=58727#c2> on
> bug 58727 <https://bugs.freedesktop.org/show_bug.cgi?id=58727> from
> Daniel Macks <mailto:dmacks at netspace.org> *
>
> I'm not a machine with compilers right now to test, but you cast the
> function-call to void rather than assigning to a temp-variable? Instead of:
>
> int unused;
> unused=some_function_with_attribute_wur(foo);
> (void) unused;
>
> Just:
>
> (void) some_function_with_attribute_wur(foo);
>
> ------------------------------------------------------------------------
> You are receiving this mail because:
>
>   * You are watching the QA Contact of the bug.
>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20140506/0b1dff2e/attachment.html>


More information about the cairo-bugs mailing list