[Gc] [bdwgc] 7.2alpha6 fails to compile with clang (#14)

Hans Aberg haberg-1 at telia.com
Tue Feb 28 15:58:08 PST 2012


On 29 Feb 2012, at 00:05, Boehm, Hans wrote:

> We seem to be having several parallel conversations about this.  Please keep further posts on the gc mailing list.
> 
> I think the crucial question is whether clang thinks
> 
> (char *)(size_t)(-1) > (char *)0
> 
> evaluates to 0 or 1, which should be a pretty simple test.  That may depend on whether you're using a 32-bit or 64-bit compilation model and possibly on other compiler flags.  We all think 1 is the right answer, though no standard requires that.  (Except possibly clang claims to be gcc, and gcc says so?)  Could someone for whom this is failing confirm that the answer is zero and post the compilation flags?

I get that error (see below) when compiling bdwg from repository with clang (see below) in 64-bit mode, but not in 32-bit mode. It compiles using llvm-gcc (see below) in 64-bitmode.

When running clang on this program:
  int main() {
  printf("%4d  ", (char *)(size_t)(-1) > (char *)0);
  return 0;
}
I get 1, both in 32- and 64-bit mode.

Hans


It is the clang one gets from latest Xvcode 4.3 developer package on OS X 10.7.3:
$ clang --version
Apple clang version 3.1 (tags/Apple/clang-318.0.45) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

LLVM-GCC:
/usr/bin/gcc -> llvm-gcc-4.2
$ /usr/bin/gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Makefile error:

libtool: compile:  clang -DHAVE_CONFIG_H -I./include -I../bdwgc/include -I./libatomic_ops/src -I../bdwgc/libatomic_ops/src -fexceptions -Wall -Wextra -g -O2 -fno-strict-aliasing -MT misc.lo -MD -MP -MF .deps/misc.Tpo -c ../bdwgc/misc.c  -fno-common -DPIC -o .libs/misc.o
../bdwgc/misc.c:953:7: error: array size is negative
      GC_STATIC_ASSERT((ptr_t)(word)(-1) > (ptr_t)0);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../bdwgc/include/private/gc_priv.h:2182:51: note: expanded from macro 'GC_STATIC_ASSERT'
# define GC_STATIC_ASSERT(expr) (void)sizeof(char[(expr)? 1 : -1])
                                                  ^~~~~~~~~~~~~~
1 error generated.
make[1]: *** [misc.lo] Error 1
make: *** [all-recursive] Error 1




More information about the Gc mailing list