[cairo-bugs] [Bug 58727] warn_unused_result noise
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed May 7 06:06:09 PDT 2014
https://bugs.freedesktop.org/show_bug.cgi?id=58727
--- Comment #4 from Ravi Nanjundappa <nravi.n at samsung.com> ---
(In reply to comment #3)
> 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;
> }
>
Agreed. But in the wrapper function approach, we will have to change the
declarations of all the cairo functions, for which the return values are really
not used anywhere.
>
> 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/20140507/2cf0a03b/attachment.html>
More information about the cairo-bugs
mailing list