bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invalid code in _G_config.h


From: John H. Spicer
Subject: Re: Invalid code in _G_config.h
Date: Mon, 14 Jan 2002 10:35:43 -0500

Andreas Jaeger wrote:
> 
> "John H. Spicer" <address@hidden> writes:
> 
> > The version of _G_config.h that is included in RedHat 7.2 contains the
> > following code:
> >
> 
> And before that code we do an include of <gconv.h>
> > typedef union
> > {
> >   struct __gconv_info __cd;
> >   struct
> >   {
> >     struct __gconv_info __cd;
> >     struct __gconv_step_data __data;
> >   } __combined;
> > } _G_iconv_t;
> >
> > This note the use of __gconv_info in the struct.  This is prohibited by
> > the C99 standard (6.7.2.1), which says:
> >
> >        [#2] A structure or union shall not contain  a  member  with
> >        incomplete  or  function  type (hence, a structure shall not
> >        contain an instance of itself, but may contain a pointer  to
> >        an  instance  of  itself),  except that the last member of a
> >        structure  with  more  than  one  named  member   may   have
> >        incomplete  array  type;  such  a  structure  (and any union
> >        containing, possibly recursively, a member that  is  such  a
> >        structure)  shall  not  be  a  member  of  a structure or an
> >        element of an array.
> 
> But __gconv_info is declared in <gconv.h>.
> 
> I don't understand the problem you see, please give some more details,
> 

I apologize, I should have included more information.

Yes, __gconv_info is declared in <gconv.h>, and the declaration there is fine.

The declaration there is:

/* Combine conversion step description with data.  */
typedef struct __gconv_info
{
  size_t __nsteps;
  struct __gconv_step *__steps;
  __extension__ struct __gconv_step_data __data __flexarr;
} *__gconv_t;

Depending on the setting of __flexarr, you get either "__data[0]" or
"__data[]".  The latter is a C99 flexible array declaration.

Which of these you get is based on this code in sys/cdefs.h:

/* Support for flexible arrays.  */
#if __GNUC_PREREQ (2,97)
/* GCC 2.97 supports C99 flexible array members.  */
# define __flexarr      []
#else
# ifdef __GNUC__
#  define __flexarr     [0]
# else
#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#   define __flexarr    []
#  else
/* Some other non-C99 compiler.  Approximate with [1].  */
#   define __flexarr    [1]
#  endif
# endif
#endif

The problem is that using "__data[]" means that gconv_info cannot be
used as a member of another struct becuase it violates the rule from
the standard that I quoted.

Please let me know if you need any further information.

John Spicer
Edison Design Group



reply via email to

[Prev in Thread] Current Thread [Next in Thread]