bug-gnulib
[Top][All Lists]
Advanced

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

mempcpy on Android


From: Reuben Thomas
Subject: mempcpy on Android
Date: Sat, 3 Nov 2018 08:11:08 +0000

I noticed a crash in a program using glob, on a line that calls mempcpy. I then noticed the following:

glob.c:836:21: warning: implicit declaration of function 'mempcpy' is invalid in C99 [-Wimplicit-function-declaration]
                d = mempcpy (dirname, p->pw_dir, home_len);
                    ^
glob.c:836:19: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                d = mempcpy (dirname, p->pw_dir, home_len);
                  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(and a bunch of other warnings). So I think this explains the crash.

The reason this happens is that mempcpy is only declared in Android's string.h #if __ANDROID_API__ >= 23

I see that the availability of this and many other Android APIs is documented, but

The gnulib documentation mentions this feature of Bionic (Android's libc), but doesn't seem to do anything about it. I guess it needs to test whether all of these functions are declared, rather than merely whether they exist in libc? Something similar is already done for truncate (commit a0f15cb).

I am using Termux as my programming environment on Android, which defines __ANDROID_API__ to 21.

--

reply via email to

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