delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2014/09/23/23:49:02

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Date: Wed, 24 Sep 2014 05:48:32 +0200 (CEST)
X-X-Sender: igor2 AT igor2priv
To: geda-user AT delorie DOT com
X-Debug: to=geda-user AT delorie DOT com from="gedau AT igor2 DOT repo DOT hu"
From: gedau AT igor2 DOT repo DOT hu
Subject: Re: [geda-user] Banging my head against the guile-for-windows wall
In-Reply-To: <lvtcdd$53a$1@ger.gmane.org>
Message-ID: <alpine.DEB.2.00.1409240535121.10941@igor2priv>
References: <20140923045453 DOT 56dc3de2 AT akka> <CAOuGh8_bfL2KJDLt-qkU7v0wS3UBkbHeej6ScVLJJfHnOR_6oQ AT mail DOT gmail DOT com> <lvssr7$lun$1 AT ger DOT gmane DOT org> <5421FF2E DOT 4010709 AT sbcglobal DOT net> <lvtcdd$53a$1 AT ger DOT gmane DOT org>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
MIME-Version: 1.0
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com


On Wed, 24 Sep 2014, Kai-Martin Knaak wrote:

> Girvin Herr wrote:
>
>> If there are warnings, what
>> other, worse bugs are in there?
>
> Lets see...
> <set-gcc-flags-to -W -Wall -ansi -pedantic>
> <build guile>
> <grep log> (6k lines(!)) there are actually quite a few warnings:
>
> (...)
> read.c: In function 'try_read_ci_chars':
> read.c:983:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
>   char *chars_read = alloca (num_chars_wanted);
>   ^
> read.c:983:22: warning: incompatible implicit declaration of built-in function 'alloca'
>   char *chars_read = alloca (num_chars_wanted);
>                      ^

#include <alloca.h> (or something else depending on your libc there) to 
get the declaration of alloca(). Alternatively an ugly workaround is to
declare it manually before the call (in case it's impossible to determine 
which .h to include or auto* gets in the way):

extern void *alloca(size_t size);

The extern is optional. Manual declaration of such builtin may cause 
problems if the C compiler is clever enough.

Background:

On many systems this is a serious problem: without an explicit 
declaration, alloca() will default to return int which is then casted to a 
pointer. This happens to work on some systems with sizeof(int) == 
sizeof(char *), but will almost always break on others. With gcc a 32 bit 
i386 is normally in the first group while x86_64 is in the second.


>
> posix.c: In function 'scm_execl':
> posix.c:1144:3: warning: passing argument 2 of 'execv' from incompatible pointer type
>   execv (exec_file, exec_argv);
>   ^
> In file included from /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/unistd.h:13:0,
>                 from ../lib/unistd.h:40,
>                 from posix.c:50:
> /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/process.h:118:42: note: expected 'const char * const*' but argument is of type 'char **'
> _CRTIMP intptr_t __cdecl __MINGW_NOTHROW execv (const char*, const char* const*);
>                                          ^
> posix.c: In function 'scm_execlp':
> posix.c:1173:3: warning: passing argument 2 of 'execvp' from incompatible pointer type
>   execvp (exec_file, exec_argv);
>   ^
> In file included from /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/unistd.h:13:0,
>                 from ../lib/unistd.h:40,
>                 from posix.c:50:
> /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/process.h:120:42: note: expected 'const char * const*' but argument is of type 'char **'
> _CRTIMP intptr_t __cdecl __MINGW_NOTHROW execvp (const char*, const char* const*);
>                                          ^
> posix.c: In function 'scm_execle':
> posix.c:1207:3: warning: passing argument 2 of 'execve' from incompatible pointer type
>   execve (exec_file, exec_argv, exec_env);
>   ^
> In file included from /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/unistd.h:13:0,
>                 from ../lib/unistd.h:40,
>                 from posix.c:50:
> /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/process.h:119:42: note: expected 'const char * const*' but argument is of type 'char **'
> _CRTIMP intptr_t __cdecl __MINGW_NOTHROW execve (const char*, const char* const*, const char* const*);
>                                          ^
> posix.c:1207:3: warning: passing argument 3 of 'execve' from incompatible pointer type
>   execve (exec_file, exec_argv, exec_env);
>   ^
> In file included from /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/unistd.h:13:0,
>                 from ../lib/unistd.h:40,
>                 from posix.c:50:
> /usr/local/src/mxe/usr/i686-pc-mingw32.static/include/process.h:119:42: note: expected 'const char * const*' but argument is of type 'char **'
> _CRTIMP intptr_t __cdecl __MINGW_NOTHROW execve (const char*, const char* const*, const char* const*);
>

I wouldn't worry much about these: exec() takes const so it won't change 
the content, you pass on non-const so you potentially don't care whether 
it changes the content. At the end, if exec() doesn't fail, it won't 
even matter anymore as exec() won't return. The only case where it would 
matter if exec() failed and returned and you'd want to do something with 
the args; but even that would matter only in the other direction when you 
had a const arg that shouldn't be changed and exec() would take 
non-const and change it.

You can suppress these warnings with an explicit cast of the argument.

Regards,

Igor2

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019