Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem::path operator/= is broken for char[1] in 1.48 (Ovanes Markarian)
From: ZNV (mejedi_at_[hidden])
Date: 2012-04-21 12:55:06


Hello Ovanes,

> This over-allocation is pretty much the same as reserving some space at the
> end of the data structure to place data together. Am I right? Why isn't it
> possible to just write char[128] or char[16] instead of char[1]?

I can't change that code because it lives in a system header.

> And if
> you know that this buffer represents some special case, why don't you pass
> it as such to filesystem? &char[0], than boost::filesystem will not assume
> it got char[1] and will be looking to '\0' marker...
>

How would I know that this buffer represents some special case?
FTS(3) library documentation says something like that:

struct _ftsent
{
   ...
   char *fts_name;
};

But the structure is really defined another way (Linux, Mac OS X):

struct _ftsent
{
   ...
   char fts_name[1];
};

I believe this discrepancy is pretty much negligible anyway.
There are huge number of programs utilizing fts(3) APIs and they don't
break.

Unfortunately boost::filesystem is another story.
It does break and it does break silently.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net