[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
count-one-bits: compilation failure with HP-UX cc
From: |
Bruno Haible |
Subject: |
count-one-bits: compilation failure with HP-UX cc |
Date: |
Sun, 13 Apr 2008 19:25:03 +0200 |
User-agent: |
KMail/1.5.4 |
The count-one-bits module fails to compile with HP-UX 11 "cc -Ae":
cc -Ae -O -DHAVE_CONFIG_H -I. -I. -I. -I.. -I./.. -I../gllib -I./../gllib
-I/nfs/visu/telecom/users/haible/gnu/arch/hp9800/include -g -c
test-count-one-bits.c
cc: "../gllib/count-one-bits.h", line 56: error 1511: Bit-field size must be a
constant.
cc: "../gllib/count-one-bits.h", line 56: error 1613: Zero-sized struct.
cc: "../gllib/count-one-bits.h", line 56: warning 504: The sizeof operator
applied to a zero-sized object.
cc: "../gllib/count-one-bits.h", line 63: error 1511: Bit-field size must be a
constant.
cc: "../gllib/count-one-bits.h", line 63: error 1613: Zero-sized struct.
cc: "../gllib/count-one-bits.h", line 63: warning 504: The sizeof operator
applied to a zero-sized object.
Very strange compiler bug:
$ cat foo.c
typedef struct { unsigned int x: ((1U >> 31 <= 3) * 2 - 1); } foo;
$ cc -Ae -c foo.c
cc: "foo.c", line 1: error 1511: Bit-field size must be a constant.
cc: "foo.c", line 1: error 1613: Zero-sized struct.
I'm working around it like this:
2008-04-13 Bruno Haible <address@hidden>
* lib/count-one-bits.h (COUNT_ONE_BITS): Rewrite verification
expression, so as to avoid HP-UX 11 cc compiler bug.
--- lib/count-one-bits.h.orig 2008-04-13 19:22:57.000000000 +0200
+++ lib/count-one-bits.h 2008-04-13 19:17:39.000000000 +0200
@@ -1,5 +1,5 @@
/* count-one-bits.h -- counts the number of 1-bits in a word.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
return BUILTIN (x);
#else
#define COUNT_ONE_BITS(BUILTIN, TYPE) \
- verify ((TYPE) -1 >> 31 >> 31 <= 3); /* TYPE has at most 64 bits */ \
+ verify (((TYPE) -1 >> 31 >> 31 >> 2) == 0); /* TYPE has at most 64
bits */ \
int count = count_one_bits_32 (x); \
if (1 < (TYPE) -1 >> 31) /* TYPE has more than 32 bits? */ \
count += count_one_bits_32 (x >> 31 >> 1); \
- count-one-bits: compilation failure with HP-UX cc,
Bruno Haible <=