This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Strings and arrays without malloc


On Thu, Mar 13, 2008 at 12:21:57PM -0700, Joel Brobecker wrote:
> > Here's some expressions which used to call malloc and still do; these
> > are operations which involve pointers, so we need to call malloc to
> > get a valid pointer for them.
> > 
> >   print *"abc"
> >   print "abc" + 1
> >   print &"abc"
> >   print strcmp ("abc", "def")
> >   print &{4, 5, 6}
> 
> Honestly, except maybe for the case where strcmp is involved, I find
> that the semantics of the expressions could be debated.

I agree.  I seriously considered breaking some more of these to remove
one of the coercions.  But strcmp ("abc", "def") obviously has to
work; I don't remember which ones I was considering breaking now.

> Or, in one expression (if I get my precedence right):
> 
>     print &(*&{4, 5, 6})[1]

Right.  But I'm not going out of my way to document this, because to
be honest I can't think of a single reason to do it.

Patch checked in!

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]