This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Undefined behavior in genautomata.c?
- From: Richard Henderson <rth at redhat dot com>
- To: Sebastian Pop <sebastian dot pop at cri dot ensmp dot fr>
- Cc: gcc at gcc dot gnu dot org, Vladimir Makarov <vmakarov at redhat dot com>
- Date: Mon, 19 Sep 2005 02:17:59 -0700
- Subject: Re: Undefined behavior in genautomata.c?
- References: <20050919091420.GA5325@napoca.cri.ensmp.fr>
On Mon, Sep 19, 2005 at 11:14:20AM +0200, Sebastian Pop wrote:
> + The fix is to declare this array as dynamically allocated as:
> +
> + decl_t *decls;
> +
> + then dynamically allocate its elements. */
> decl_t decls [1];
No, the fix is
#ifdef HAVE_FLEXIBLE_ARRAY_MEMBERS
decl_t decls[];
#else
decl_t decls[1];
#endif
Where
/* 1 if we have C99 flexible array members. */
#if !defined(HAVE_DESIGNATED_INITIALIZERS)
#define HAVE_DESIGNATED_INITIALIZERS \
((GCC_VERSION >= XXX) || (__STDC_VERSION__ >= 199901L))
#endif
where XXX ought to be looked up; 3.2 or 3.3 is probably right.
r~