Re: SWIG: Bug with 'C' arrays of zero size ?

Arnaud RICHARD <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <AM7PR10MB38579DAB049872223C8A1D22F69C0@AM7PR10MB3857.EURPRD10.PROD.OUTLOOK.COM>
As far as I know, in C data[] is not defining a 0-sized array but a pointer equivalent to *data with a hint for the reader that the pointer will be used for an array.
Considering this, SWIG behavior seems correct.

Arnaud

> -----Original Message-----
> From: Alberto Luaces <[email protected]>
> Sent: Saturday, June 13, 2020 10:31
> To: [email protected]
> Subject: Re: [Swig-user] SWIG: Bug with 'C' arrays of zero size ?
> 
> On Fri, Jun 12, 2020, at 10:37, Terry Barnaby wrote:
> > Hi,
> >
> > If you have a data structure like the following all is well:
> >
> > struct DataBlock {
> >      Header    header;
> >      char        data[4];    ///< The packet data };
> >
> > However if you have a data structure that has a zero length array like
> > the following, SWIG considers the "char data[]" as a pointed to data
> > and tries to delete[] and allocate memory for it.
> >
> > struct DataBlock {
> >     Header    header;
> >      char        data[];    ///< The packet data };
> >
> > I think this is a bug ?
> 
> Are you using C++?  It seems that zero-sized arrays are not allowed:
> 
> https://stackoverflow.com/questions/6180012/array-with-size-0#6180200
> 
> 
> _______________________________________________
> Swig-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/swig-user

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.