[Bug 213] -SNAP-20020410 fails to compile under AIX 4.3.3

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Fri Apr 12 06:51:56 EST 2002


http://bugzilla.mindrot.org/show_bug.cgi?id=213





------- Additional Comments From pspencer at fields.utoronto.ca  2002-04-12 06:51 -------
It seems the IBM compiler will not do pointer arithmetic at compile time.

For example, assuming pointers are compatible with unsigned longs, the following
program will not compile using the IBM compiler xlc, but using gcc it will
compile just fine (printing "6" when it runs, assuming ints are 4 bytes long):

int main() {
    char tmp[(unsigned long)((int *)(10) - 1)];
    printf ("size is %d\n", sizeof(tmp));
}

Without the "- 1", the program will compile and run correctly (printing "10")
using either xlc or gcc.

The CMSG_SPACE macro used in monitor_fdpass.c uses the ALIGN macro, which AIX
defines in sys/socket.h using pointer arithmetic.

One fix is to undefine AIX's ALIGN macro in favour of openssh's which does not
use pointer arithmetic and works just fine. A quick-and-dirty way of doing this
is to apply the following patch to defines.h then run configure with
CFLAGS="-DCOMPILER_CHOKES_ON_SYSTEM_ALIGN":

--- defines.h.orig      Sat Apr  6 18:52:05 2002
+++ defines.h   Thu Apr 11 15:51:06 2002
@@ -447,6 +447,11 @@
 #ifndef ALIGNBYTES
 #define ALIGNBYTES     (sizeof(int) - 1)
 #endif
+#ifdef COMPILER_CHOKES_ON_SYSTEM_ALIGN
+#ifdef ALIGN
+#undef ALIGN
+#endif
+#endif
 #ifndef ALIGN
 #define ALIGN(p)       (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
 #endif

A better fix would be to have configure try to compile the following test
program:

#include <sys/socket.h>
#ifndef ALIGN
#define ALIGN(p) p
#endif
int main() {
        char tmp[ALIGN(1)];
}

If sys/socket.h exists but this compilation fails, configure could set the
COMPILER_CHOKES_ON_SYSTEM_ALIGN flag.

However, since I have no experience with autoconf I'll let someone else suggest
the appropriate patch.

An alternative is to simply always use openssh's ALIGN macro (i.e., omit the
#ifdef COMPILER_CHOKES_ON_SYSTEM_ALIGN from the defines.h patch) but I don't
know if that would break anything on a system where the system's ALIGN macro has
to be used because of something special it does.

Two other changes are also needed to make this snapshot compile with the older
version (4) of IBM's C compiler that I am using: It will not allow "enum
{a,b,...,x,}" with nothing after the final comma -- this occurs twice in log.h
and once in monitor.h, and if running in strict ANSI mode it will not allow the
redefinition of TILDE in openbsd-compat/glob.c (the system header files already
define it). These issues may apply to released versions of openssh also; I've
never tried compiling it with IBM's compiler until I saw this bug report. If
anyone wants me to I could open up a new bug report and attach a patch. I
personally don't care about them too much since I use gcc, and presumably the
current IBM compiler is okay since the reporter of this bug didn't mention any
such problems.





------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the openssh-unix-dev mailing list