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

Abramo Bagnara abramo.bagnara at gmail.com
Mon Jun 6 20:00:28 CEST 2011


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 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...)

The variable might be useful for gdb sessions.



More information about the PPL-devel mailing list