bugGuile - Bugs: bug #29395, build fails on HP-UX 11.31: excess...

 
 

bug #29395: build fails on HP-UX 11.31: excess elements in array initializer

Submitter:  Alexander Gattin <xrgtn>
Submitted:  Wed 31 Mar 2010 01:22:06 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 31 Mar 2010 01:22:06 PM UTC, original submission:  

ilink@tunis:~/src/guile-1.8.7/libguile > gcc -DHAVE_CONFIG_H -I.. -I.. -I.. -D_XOPEN_SOURCE=600 -I/comptel/ilink/xxx/include -D_XOPEN_SOURCE=600 -I/comptel/ilink/xxx/include -D_REENTRANT -pthread -g -O2 -Wall -Wmissing-prototypes -Werror -MT libguile_la-async.lo -MD -MP -MF .deps/libguile_la-async.Tpo -c async.c  -fPIC -DPIC -o .libs/libguile_la-async.o
async.c:162: warning: excess elements in array initializer
async.c:162: warning: (near initialization for `async_mutex.__m_short')
async.c:162: warning: excess elements in array initializer
async.c:162: warning: (near initialization for `async_mutex.__m_short')
... above warnings are repeated up to 44 total warning lines ...

The statement that produces this warning/error (please note that I use gcc, and Makefile wuns it with -Wall -Werror) is the next one:

static scm_i_pthread_mutex_t async_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;

SCM_I_PTHREAD_MUTEX_INITIALIZER is [wrongly] autocofigured as {PTHREAD_HPUX_INITIALIZER};

The pthread_mutex_t is defined on HP-UX this way:
#  ifdef _LP64_
#    define __MPOINTER          void    *__m_ptr
#    define __POINTER_SET               ((void *) 1LL)
#  else
#    define __MPOINTER          int     __m_pad; \
                                void    *__m_ptr
#    define __POINTER_SET               0, ((void *) 1L)
#  endif

struct __pthread_mutex {
        short           __m_short[2];
        int             __m_int;
        int             __m_int1[4];
        __MPOINTER;
        int             __m_int2[2];
        int             __m_int3[4];
        short           __m_short2[2];
        int             __m_int4[5];
        int             __m_int5[2];
};

typedef struct __pthread_mutex pthread_mutex_t;

You can see that it is a complex struct (struct that contains arrays). But HP-UX's initializer is flat list:

#define __SPNLCK_INITIALIZER \
        1, 1, 1, 1, \
        __POINTER_SET, \
        1, \
        0

#define PTHREAD_MUTEX_INITIALIZER  { \
        __PTHREAD_MUTEX_VALID, 0, \
        (PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE), \
        __SPNLCK_INITIALIZER, \
        0, 0, -1, 0, \
        0, __LWP_MTX_VALID, 0, 1, 1, 1, 1, \
        0, 0 \
        }

gcc would like the initializer to have nested curly braces for every array that's nested in the pthread_mutex_t struct, like this:

#define PTHREAD_MUTEX_INITIALIZER2 { \
        {__PTHREAD_MUTEX_VALID, 0}, \
        (PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE), \
        {1, 1, 1, 1}, \
        __POINTER_SET, \
        {1, 0}, \
        {0, 0, -1, 0}, \
        {0, __LWP_MTX_VALID}, {0, 1, 1, 1, 1}, \
        {0, 0} \
        }

And then everything will be fine.

There are 2 problems, though:

1. we cannot modify system HP-UX headers (but it's OK to override system pthread.h with manually hacked gcc/ia64-hp-hpux11.31/3.4.6/include/sys/pthread.h)

2. ./configure tries to solve the problem in completely broken way. IMHO the 'excess element' is much more dangerous warning than 'missing braces' one (another workaround is to configure and build guile with CFLAGS="-Wno-missing-braces")

I think ./configure should be changed to try PTHREAD_MUTEX_INITIALIZER both with and without braces. And probably with both -Wno-missing-braces and -Wmissing-braces CFLAGS.

Alexander Gattin <xrgtn>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #20075:  pthread.h.patch added by xrgtn (4KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by xrgtn (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-03-31 xrgtn Attached File- Added pthread.h.patch, #20075

    Back to the top

    Powered by Savane 3.13-54b4.
    Corresponding source code