This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: add/assign problem, part 2.
- From: Andrew Haley <aph at gcc dot gnu dot org>
- To: DCH <david at carter-hitchin dot clara dot co dot uk>
- Cc: David Mebane <david dot mebane at mse dot gatech dot edu>, gcc-help at gcc dot gnu dot org
- Date: Mon, 1 Jan 2007 14:18:23 +0000
- Subject: Re: add/assign problem, part 2.
- References: <1167585956.4597f2a4add1b@webmail.mail.gatech.edu> <7.0.1.0.0.20061231173507.021f43e8@carter-hitchin.clara.co.uk> <17816.62387.306846.896735@zebedee.pink> <7.0.1.0.0.20070101130944.021d58a8@carter-hitchin.clara.co.uk>
DCH writes:
>
> > > I haven't actually compiled up your program, but immediately alarm
> > > bells are ringing when I see things like
> > >
> > > a = *(vec + i)
> >
> >It's just a nonstandard way to write vec[i]. I mean, it's weird, but
> >it's not actually wrong. :-)
>
> Sure. The point I was making is that the variable i was being
> incremented up to a ceiling value
> which was determined by a function parameter, i.e. you're trusting
> whoever calls your function
> to get the value of this parameter correct. Much safer to iterate
> with a vector:
>
> for (size_t i = 0, length = vec.size(); i < length; ++i) {
> do something with vec[i];
> }
Right, but that's a red herring here: the code in question doesn't
seem to be getting that wrong. I don't agree with your point in
general, but it seems to be at best only tangentially related to the
OP's problem.
What we need from the OP is a description of the expected behaviour,
and then we can discover whether this really is a compiler bug.
Andrew.