Bug 42992 - test case for apr_atomic_casptr uses incompatible pointer type
Summary: test case for apr_atomic_casptr uses incompatible pointer type
Status: RESOLVED FIXED
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: 0.9.12
Hardware: Other Linux
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2007-07-28 21:18 UTC by Carlo Marcelo Arenas Belon
Modified: 2007-07-29 08:02 UTC (History)
0 users



Attachments
uses volatile void * as the first parameter for apr_atomic_casptr for everyone but netware (466 bytes, patch)
2007-07-28 23:42 UTC, Carlo Marcelo Arenas Belon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlo Marcelo Arenas Belon 2007-07-28 21:18:47 UTC
as shown by following output excerpt from make check :

testatomic.c: In function 'check_basic_atomics':
testatomic.c:84: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type
testatomic.c:91: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type
testatomic.c:98: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type

problem is only present in the 0.9 branch including the current HEAD and the
last released version 0.9.14 and is triggered by a mismatch in the first
parameter pointer which is defined in all architectures as "volatile void **"
but is defined in the test as a dereference to "void *" (netware has a different
ABI, presumably by mistake and uses void **)
Comment 1 Davi Arnaut 2007-07-28 22:37:39 UTC
I don't see the warning and neither the dereference to "void *" -- can't
dereference void pointers..

Which compiler are you using? version?
Comment 2 Carlo Marcelo Arenas Belon 2007-07-28 23:42:34 UTC
Created attachment 20560 [details]
uses volatile void * as the first parameter for apr_atomic_casptr for everyone but netware

#ifdef required so that NETWARE can be kept using void * and respecting current
ABI (for 0.9.x branch).

if ABI doesn't need to be kept stable and is better to use the same ABI that
1.x has then ifdef could be removed and the first parameter changed in
include/apr_atomic.h (can provide a patch as well, as that is what I did for my
own tree which uses apr statically and I don't care about ABI
incompatibilities)
Comment 3 Carlo Marcelo Arenas Belon 2007-07-28 23:48:38 UTC
got warning with either gcc-4.1.2 or gcc-3.4.6 in amd64 linux as shown below :

$ gcc -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure -
-prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/l
ib/gcc/x86_64-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/x86_64-pc
-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/man --in
fodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4 --host=x86_64-pc-linux-gnu
 --build=x86_64-pc-linux-gnu --disable-altivec --disable-nls --with-system-zlib 
--disable-checking --disable-werror --enable-secureplt --disable-libunwind-excep
tions --enable-multilib --disable-libmudflap --disable-libssp --enable-languages
=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit
 --enable-clocale=gnu
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2)
$ make testatomic.o
gcc -g -O2 -pthread   -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE  
-I../include  -c testatomic.c
testatomic.c: In function 'check_basic_atomics':
testatomic.c:84: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type
testatomic.c:91: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type
testatomic.c:98: warning: passing argument 1 of 'apr_atomic_casptr' from
incompatible pointer type

Comment 4 Carlo Marcelo Arenas Belon 2007-07-28 23:58:26 UTC
my comment about a "dereference for void *" was obviously incorrect, what I
meant to refer to was the use of the "address of" operator for casptr as the
first parameter of apr_atomic_casptr as shown by the following excerpt from
testatomic.c's check_basic_atomics.

  void *casptr;
  casptr = NULL;
  oldptr = apr_atomic_casptr(&casptr, &object1, 0);

the definition (from include/apr_atomic.h) for apr_atomic_casptr says :

  void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
Comment 5 Davi Arnaut 2007-07-29 08:02:06 UTC
Patch committed to the 0.9.x branch in revision 560724:

http://svn.apache.org/viewvc?view=rev&revision=560724