Bruno Haible wrote:
Emacs 25.1 cannot be built with this compiler.
Thanks for looking into this. Ouch. It looks like HP-UX cc has serious bugs in
its implementation of C99 flexible array members. I added this issue to
emacs/etc/PROBLEMS, and am suggesting GCC instead of HP-UX cc for people who
want to build Emacs on HP-UX. See:
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a09473261c8b11243e68d84c5dc2448d65a67e77
CCLD ebrowse
cc: "ebrowse.c", line 281: error 1687: Illegal use of flexible array: structs
with FAMs cannot be members of other structs.
This suggests that the HP-UX cc flexible array member bug is as follows: if a
struct X contains a 'struct Y *' member where 'struct Y' has a flexible array
member, the compiler incorrectly rejects the definition of struct X. Does the
attached Gnulib patch suffice to detect the HP-UX cc bug? If so, this should fix
Emacs's problem with flexible array members on HP-UX cc. I installed this patch
into Gnulib since it shouldn't hurt even if it doesn't catch the HP-UX cc bug.
For the problem with __attribute__ ((__aligned__ (8))), does it suffice to put
the declaration after the identifier? E.g., does this compile:
int foo __attribute__ ((__aligned__ (8))) = 10;
whereas this does not compile?
int __attribute__ ((__aligned__ (8))) bar = 20;
If so, I think we can work around this problem in Emacs (even if we cannot solve
the problem in general for Gnulib stdalign), and something like the patch you
proposed should suffice for Gnulib (although we'd also need to fix
m4/stdalign.m4 to keep it in sync with lib/stdalign.in.h).
Also, in your build of Emacs 25.1, is the symbol HAVE_STRUCT_ATTRIBUTE_ALIGNED
defined in src/config.h?
From 089d89e4a28e2b1b19c67114fea1fd810a3ccd5b Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 17 Mar 2017 01:37:34 -0700
Subject: [PATCH] flexmember: try to detect HP-UX 11.31 cc bug
Problem reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00066.html
* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
Attempt to detect bug in HP-UX 11.31 cc.
---
ChangeLog | 8 ++++++++
m4/flexmember.m4 | 7 +++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1843733..34606a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-17 Paul Eggert <egg...@cs.ucla.edu>
+
+ flexmember: try to detect HP-UX 11.31 cc bug
+ Problem reported by Bruno Haible in:
+ http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00066.html
+ * m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
+ Attempt to detect bug in HP-UX 11.31 cc.
+
2017-03-16 Bruno Haible <br...@clisp.org>
stdint: Fix test compilation failure with HP-UX 11 cc.
diff --git a/m4/flexmember.m4 b/m4/flexmember.m4
index 35580ac..9d3b50d 100644
--- a/m4/flexmember.m4
+++ b/m4/flexmember.m4
@@ -1,4 +1,4 @@
-# serial 4
+# serial 5
# Check for flexible array member support.
# Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
@@ -17,12 +17,15 @@ AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
[[#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
- struct s { int n; double d[]; };]],
+ struct m { struct m *next, **list; char name[]; };
+ struct s { struct s *p; struct m *m; int n; double d[]; };]],
[[int m = getchar ();
size_t nbytes = offsetof (struct s, d) + m * sizeof (double);
nbytes += sizeof (struct s) - 1;
nbytes -= nbytes % sizeof (struct s);
struct s *p = malloc (nbytes);
+ p->p = p;
+ p->m = NULL;
p->d[0] = 0.0;
return p->d != (double *) NULL;]])],
[ac_cv_c_flexmember=yes],
--
2.7.4