bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

execl, execle, execlp: Fix compilation error with gcc 14


From: Bruno Haible
Subject: execl, execle, execlp: Fix compilation error with gcc 14
Date: Sun, 22 Dec 2024 04:42:47 +0100

On a recent version of MSYS2, I see these compilation errors:

../../gllib/execl.c:75:19: error: passing argument 2 of 'rpl_execv' from 
incompatible pointer type [-Wincompatible-pointer-types]
../../gllib/execle.c:76:20: error: passing argument 2 of 'rpl_execve' from 
incompatible pointer type [-Wincompatible-pointer-types]
../../gllib/execlp.c:75:20: error: passing argument 2 of 'rpl_execvp' from 
incompatible pointer type [-Wincompatible-pointer-types]

They were warnings with previous gcc releases. Now they are errors.
Casts are necessary to work around the broken declarations of execv*()
in POSIX.


2024-12-22  Bruno Haible  <bruno@clisp.org>

        execl, execle, execlp: Fix compilation error with gcc 14.
        * lib/execl.c (execl): Cast second argument of execv.
        * lib/execle.c (execle): Cast second argument of execve.
        * lib/execlp.c (execlp): Cast second argument of execvp.

diff --git a/lib/execl.c b/lib/execl.c
index 46818b111f..5ddad931e4 100644
--- a/lib/execl.c
+++ b/lib/execl.c
@@ -72,7 +72,7 @@ execl (const char *program, const char *arg0, ...)
   }
 
   /* Invoke execv.  */
-  execv (program, argv);
+  execv (program, (char * const *) argv);
 
   /* If execv returned, it must have failed.  */
   int saved_errno = errno;
diff --git a/lib/execle.c b/lib/execle.c
index 3a93a694ea..fb4917771e 100644
--- a/lib/execle.c
+++ b/lib/execle.c
@@ -73,7 +73,7 @@ execle (const char *program, const char *arg0, ...)
   va_end (args);
 
   /* Invoke execve.  */
-  execve (program, argv, env);
+  execve (program, (char * const *) argv, env);
 
   /* If execve returned, it must have failed.  */
   int saved_errno = errno;
diff --git a/lib/execlp.c b/lib/execlp.c
index 9c18af332f..2c1b5799dd 100644
--- a/lib/execlp.c
+++ b/lib/execlp.c
@@ -72,7 +72,7 @@ execlp (const char *program, const char *arg0, ...)
   }
 
   /* Invoke execvp.  */
-  execvp (program, argv);
+  execvp (program, (char * const *) argv);
 
   /* If execvp returned, it must have failed.  */
   int saved_errno = errno;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]