fix hotspot build failures with -D_FORTIFY_SOURCE=2 and -Wformat=1

Kelly O'Hair Kelly.Ohair at Sun.COM
Wed Dec 3 12:24:55 PST 2008


Casting a function call to (void) is a well defined, well understood
and explicit language syntax. The function return is being explicitly ignored.
If we have to jump through hoops for this gcc then maybe the -Werror should
just be turned off for this gcc release in the Makefiles.

-kto

Christian Thalinger wrote:
> On Wed, 2008-12-03 at 14:46 +0100, Matthias Klose wrote:
>>           int fn () __attribute__ ((warn_unused_result));
>>           int foo ()
>>           {
>>             if (fn () < 0) return -1;
>>             (void) fn ();
>>             return 0;
>>           }
>>
>> gcc (4.3.x, 4.4) still warns about the unused return value.
> 
> I see the problem.  write is defined with __wur (which is most likely
> __attribute__ ((warn_unused_result)), I did not check) in glibc-2.7, but
> not in e.g. glibc-2.3.6, and GCC warns about it even when a (void) cast
> is used.
> 
> I'd say this is a bug in GCC.  When I explicitly ask for ignoring the
> return value, it should do it.
> 
> - Christian
> 



More information about the hotspot-dev mailing list