------- Comment #4 from pinskia at gcc dot gnu dot org  2008-03-14 12:08 -------
(In reply to comment #3)
> (In reply to comment #2)
> > >This is the design of warn_unused_result, you cannot ignore the value, 
> > >that is why casting to void does not work.
> 
> I agree with the reporter. There should be a way to tell the compiler to avoid
> warning for particular cases. Casting to void seems to be the best way to do
> that.

http://gcc.gnu.org/ml/gcc/2006-11/msg00468.html

The original patch has a testcase explicitly checking for the case where cast
to void is there:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00875.html
+  (void) check1 ();    /* { dg-warning "ignoring return value of" } */

As for the other stuff, the manual says:

+The @code{warn_unused_result} attribute causes a warning to be emitted
+if a caller of the function with this attribute does not use its
+return value.  This is useful for functions where not checking
+the result is either a security problem or always a bug, such as
[EMAIL PROTECTED]

The return value is used, it is assigned to a variable, just that variable is
not used which is a different story.

I think we can declare this bug as invalid really.

-- Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35579

Reply via email to