Flexible array bug?
Hi,
I have run into a strange problem with the Sun Studio 11 compiler and flexible arrays.
The C99 code below contains a struct, "flex_struct", which has a flexible array member.
When I compile the file "flex_problem.c", see below, I get an error message saying that "const_func"
is redeclared. (Note that the compiler does not complain about the non-const version "func".)
Is this a known problem?
// file: flex_problem.h
struct flex_struct;
void func(struct flex_struct *sp);
void const_func(const struct flex_struct *csp);
// end of file flex_problem.h
// file: flex_problem.c
#include "flex_problem.h"
struct flex_struct {
int i;
int iv[];
};
void
func(struct flex_struct *p)
{
}
void
const_func(const struct flex_struct *cp)
{
}
// end of file flex_problem.c
liquidator-623>cc -# -c -xc99=all flex_problem.c
### Note: NLSPATH = /pub/SUNWspro11/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/pub/SUNWspro11/pr od/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
###command line files and options (expanded):
### -c -xc99=%all flex_problem.c
/pub/SUNWspro11/prod/bin/acomp -xldscope=global -i flex_problem.c -y-fbe -y/pub/SUNWspro11/prod/bin/fbe -y-xarch=generic -y-o -yflex_problem.o -y-verbose -y-xmemalign=8i -y-xthreadvar=no%dynamic -y-comdat -xdbggen=no%stabs+dwarf2+usedonly -fparam_ir -Qy -D__SunOS_5_10 -D__SUNPRO_C=0x580 -D__SVR4 -D__unix -D__sun -D__sparc -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -Xa -D__PRAGMA_REDEFINE_EXTNAME -Dunix -Dsun -Dsparc -D__RESTRICT -xc99=%all -D__FLT_EVAL_METHOD__=0 -c99OS -I/pub/SUNWspro11/prod/include/cc "-g/pub/SUNWspro11/prod/bin/cc -c -xc99=all " -fsimple=0 -D__SUN_PREFETCH -destination_ir=yabe
"flex_problem.c", line 17: identifier redeclared: const_func
current : function(pointer to const struct flex_struct {int i, array[-1] of int iv}) returning void
previous: function(pointer to const struct flex_struct {int i, array[-1] of int iv}) returning void : "flex_problem.h", line 6
cc: acomp failed for flex_problem.c
liquidator-624>cc -V
cc: Sun C 5.8 Patch 121015-02 2006/03/29
usage: cc [ options] files. Use 'cc -flags' for details
liquidator-625>

