bugGNU cpio - Bugs: bug #66297, c23 and xstat's interface

 
 

bug #66297: c23 and xstat's interface

Submitter:  Jeffrey Cliff <themusicgod1>
Submitted:  Sat 05 Oct 2024 09:27:02 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Oct 2024 09:27:02 PM UTC, original submission:  

cpio (GNU cpio) 2.15
gcc (GCC) 15.0.0 20240509 (experimental)
CFLAGS=" -std=gnu23 -Oz -march=native " (ie compile with a C23-compatible gcc)

Resulted in compilation error due to variable 'xstat':

copypass.c: In function ‘process_copy_pass’:
copypass.c:104:12: error: too many arguments to function ‘xstat’
  104 |       if ((*xstat) (input_name.ds_string, &in_file_stat) < 0)
      |           ~^~~~~~~
copyout.c: In function ‘process_copy_out’:
copyout.c:646:12: error: too many arguments to function ‘xstat’
  646 |       if ((*xstat) (input_name.ds_string, &file_stat) < 0)
      |           ~^~~~~~~
main.c: In function ‘parse_opt’:
main.c:407:13: error: assignment to ‘int ()(void)’ from incompatible pointer type ‘int ()(const char restrict,  struct stat restrict)’ [-Wincompatible-pointer-types]
  407 |       xstat = stat;
      |             ^
make[2]: * [Makefile:1859: copypass.o] Error 1
make[2]: * Waiting for unfinished jobs....
main.c: In function ‘process_args’:
main.c:594:9: error: assignment to ‘int ()(void)’ from incompatible pointer type ‘int ()(const char restrict,  struct stat restrict)’ [-Wincompatible-pointer-types]
  594 |   xstat = lstat;
      |         ^
main.c:615:26: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
  615 |       CHECK_USAGE (xstat != lstat, "--dereference", "--extract");
      |                          ^~
main.c:92:6: note: in definition of macro ‘CHECK_USAGE’
   92 |  if (cond) \
      |      ^~~~

this is because of a change in the level of strictness in function definitions in c23 for void functions (for a similar change in semantics of C see libgomp https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114216 quote "Basically `()` as the function paramaters is no longer the same as `(...)` but rather the same as `(void)`." )

the following change, instead of using the generic (...) uses the definition of what xstat actually gets used by (ie giving more of a clue to the compiler). If this isn't appropriate for some reason (...) should be used instead.

Jeffrey Cliff <themusicgod1>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56478:  cpio-c23.patch added by themusicgod1 (883B - 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 themusicgod1 (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.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-10-05 themusicgod1 Attached File- Added cpio-c23.patch, #56478

    Back to the top

    Powered by Savane 3.14-7003.
    Corresponding source code