[PPL-devel] [GIT] ppl/ppl(master): Silenced gcc warnings.

Anthony Foiani anthony.foiani at gmail.com
Mon Jun 6 19:04:49 CEST 2011


Abramo, greetings --

On Mon, Jun 6, 2011 at 10:55 AM, Abramo Bagnara
<abramo.bagnara at gmail.com> wrote:

> Silenced gcc warnings.

For these particular warnings, wouldn't it be better to simply never
assign the result in the first place, instead of saving the result and
then doing the "(void)" trick on it?

That is, instead of:

> --- a/tests/BD_Shape/relations3.cc
> +++ b/tests/BD_Shape/relations3.cc
> @@ -81,6 +81,7 @@ test03() {
>     // it is illegal to use a generator that is
>     // dimensional incompatible with the BDS.
>     Poly_Gen_Relation rel = bds.relation_with(ray(C));
> +    (void) rel;
>   }
>   catch (std::invalid_argument& e) {
>     nout << "std::invalid_argument: " << endl;

Just do this (warning, hand-edited patch):

> --- a/tests/BD_Shape/relations3.cc
> +++ b/tests/BD_Shape/relations3.cc
> @@ -81,6 +81,6 @@ test03() {
>     // it is illegal to use a generator that is
>     // dimensional incompatible with the BDS.
> -    Poly_Gen_Relation rel = bds.relation_with(ray(C));
> +     bds.relation_with(ray(C));
>   }
>   catch (std::invalid_argument& e) {
>     nout << "std::invalid_argument: " << endl;

This seems like a nicer and more self-documenting way to silence the
warning. (So far as I know, GCC doesn't warn when you don't use the
return value from a function or method call; that goes back to the
good old "printf" days...)

I haven't looked at the history of that code; was there ever a reason
to capture the return value? If it's sufficiently old code, it might
be that it was originally done that way before exceptions were used,
to catch error return values. The other scenario I can imagine is if
the original code had various asserts or other tests after the
assignment which were removed once the code was trusted (or moved into
a separate test suite). Hm... this *is* the test suite.

Anyway.

Thanks again for your work on the library!

Best regards,
Anthony Foiani



More information about the PPL-devel mailing list