patchGNU Gengetopt - Patches: patch #10402, Fix compiler warnings on GCC13

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #10402: Fix compiler warnings on GCC13

Submitter:  Sebastian Muxel <muxelplexer>
Submitted:  Sat 14 Oct 2023 11:47:14 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Tue 17 Oct 2023 09:53:19 AM UTC, comment #2: 


> I do not write C++ daily anymore, so I am unsure of the exact
> implications here.  But if it does compile ...
> Alternative would be ifdef with pre- >and post- C++11 branches.


Interestingly struct print_f seems completely unused so it would
only be an issue for pair_print_f.

I'm not an expert on implicit move/copy semantics but considering
we only have a constructor and nothing else it should be fine
according to my understanding.

Also thanks for the quick reply, i would not have guessed that this
will be handled this fast :)

Sebastian Muxel <muxelplexer>
Mon 16 Oct 2023 12:08:41 PM UTC, comment #1: 

Hello,

thanks for the report and patch.

> -Werror=mismatched-new-delete
> In src/gengetopt 'n' is being allocated with operator new() but freed with free().


Applied, thanks.

> -Werror=deprecated-declarations
> In gm_utils.h print_f and pair_print_f are defined as
> std::unary_functions. These have been deprecated/removed in C++ 11/17.


This patch does break compatibility with C++98 and C++03.  So it needs to be solved in different way.  However it seems that just deleting the `: public std::unary_function ...' does allow compilation both under 98 and 23.  Any opinions on this fix:

@@ -117,7 +117,7 @@ bool string_contains(const char *s, const char *tofind);
  * Function object to print something into a stream (to be used with for_each)
  */
 template<class T>
-struct print_f : public std::unary_function<T, void>
+struct print_f
 {
     print_f(std::ostream& out, const string &s = ", ") : os(out), sep(s) {}
     void operator() (T x) { os << x << sep; }
@@ -129,7 +129,7 @@ struct print_f : public std::unary_function<T, void>
  * Function object to print a pair into two streams (to be used with for_each)
  */
 template<class T>
-struct pair_print_f : public std::unary_function<T, void>
+struct pair_print_f
 {
     pair_print_f(std::ostream& out1, std::ostream& out2, const string &s = ", ") :
         os1(out1), os2(out2), sep(s) {}

?  I do not write C++ daily anymore, so I am unsure of the exact implications
here.  But if it does compile ...  Alternative would be ifdef with pre- and
post- C++11 branches.

> -Werror=unused-result
> I'm unsure if i'm missing something here? It seems like gm_utils is supposed
> not to do anything on this line so it should be fair to remove.


I am pretty sure you are right.

> + an error about comparing the result of pointer and integer arithmetics with
> NULL (scanner.ll)


Thanks, fixed.

Gray Wolf <gray_wolf>
Group administrator
Sat 14 Oct 2023 11:47:14 PM UTC, original submission:  

After trying to compile on GCC 13.2.1 i have gotten these errors which are being addressed by this patch:

-Werror=mismatched-new-delete
In src/gengetopt 'n' is being allocated with operator new() but freed with free().

-Werror=deprecated-declarations
In gm_utils.h print_f and pair_print_f are defined as std::unary_functions. These have been deprecated/removed
in C++ 11/17.

-Werror=unused-result
I'm unsure if i'm missing something here? It seems like gm_utils is supposed not to do anything on this line so it should be fair
to remove.

+ an error about comparing the result of pointer and integer arithmetics with NULL (scanner.ll)

Sebastian Muxel <muxelplexer>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #55236:  fix-build.patch added by muxelplexer (3KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gray_wolf (Posted a comment)
  • -email is unavailable- added by muxelplexer (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-14 muxelplexer Attached File- Added fix-build.patch, #55236

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code