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

Module: ppl/ppl Branch: master Commit: 9248b10e00497f2e57ce2f99256c73fa853f8271 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9248b10e00497...
Author: Abramo Bagnara abramo.bagnara@gmail.com Date: Mon Jun 6 18:55:31 2011 +0200
Silenced gcc warnings.
---
tests/BD_Shape/relations3.cc | 1 + tests/Box/relations4.cc | 1 + tests/Octagonal_Shape/relatwithcons2.cc | 1 + tests/Octagonal_Shape/relatwithgen1.cc | 1 + 4 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/tests/BD_Shape/relations3.cc b/tests/BD_Shape/relations3.cc index 9a35ae8..2e3c44a 100644 --- 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; diff --git a/tests/Box/relations4.cc b/tests/Box/relations4.cc index 26de159..baf2225 100644 --- a/tests/Box/relations4.cc +++ b/tests/Box/relations4.cc @@ -432,6 +432,7 @@ test19() { try { // This tests the space dimension exception.. Poly_Con_Relation rel = box.relation_with((A + B %= 1) / 9); + (void) rel; } catch (std::invalid_argument& e) { nout << "std::invalid_argument: " << endl; diff --git a/tests/Octagonal_Shape/relatwithcons2.cc b/tests/Octagonal_Shape/relatwithcons2.cc index 2792944..d60d9c7 100644 --- a/tests/Octagonal_Shape/relatwithcons2.cc +++ b/tests/Octagonal_Shape/relatwithcons2.cc @@ -306,6 +306,7 @@ test14() { // it is illegal to use a constraint that is not dimension-compatible // with the octagon. Poly_Con_Relation rel = oc.relation_with(-C - B <= 2); + (void) rel; } catch (std::invalid_argument& e) { nout << "std::invalid_argument: " << e.what() << endl; diff --git a/tests/Octagonal_Shape/relatwithgen1.cc b/tests/Octagonal_Shape/relatwithgen1.cc index 8163bb7..13026cd 100644 --- a/tests/Octagonal_Shape/relatwithgen1.cc +++ b/tests/Octagonal_Shape/relatwithgen1.cc @@ -272,6 +272,7 @@ test12() { // it is illegal to use a generator that is // dimensional incompatible with the OS. Poly_Gen_Relation rel = oc.relation_with(ray(C)); + (void) rel; } catch (std::invalid_argument& e) { nout << "std::invalid_argument: " << e.what() << endl;

Abramo, greetings --
On Mon, Jun 6, 2011 at 10:55 AM, Abramo Bagnara abramo.bagnara@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));
} catch (std::invalid_argument& e) { nout << "std::invalid_argument: " << endl;bds.relation_with(ray(C));
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

Il 06/06/2011 19:04, Anthony Foiani ha scritto:
Abramo, greetings --
On Mon, Jun 6, 2011 at 10:55 AM, Abramo Bagnara abramo.bagnara@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));
} catch (std::invalid_argument& e) { nout << "std::invalid_argument: " << endl;bds.relation_with(ray(C));
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...)
The variable might be useful for gdb sessions.
participants (2)
-
Abramo Bagnara
-
Anthony Foiani