Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: For C Experts

2006-03-30 by Robert Adsett

Quoting brendanmurphy37 <brendan.murphy@...>:

>
> It's not at all clear what the actual intent of the programmer is for
> this: what's actually coded is a long way from memcpy, regardless of
> any assumptions you make about what the compiler does.

Actually, I thought (still think) the intent is pretty obvious.  Take whatever
'starts' at buf[i] and put it into an int.  That can be implemented pretty
straightforwardly by a memcpy.  What do you see that memcpy wouldn't do?

> I'm actually a bit surprised that GCC gives a warning: the only
> really incorrect line (language-wise) is the "ip = (int *)&buf[i];"
> one, but the programmer here gives an explicit direction to the
> compiler (by using the explicit type cast) that they know what
> they're doing. Most compilers would I suspect not issue a warning in
> that circumstance.

I'm going to have to see what lint does when confronted with this.  I expect
it's going to be pretty verbose ;)

> All of which begs the question: what is the original intent?

Robert

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.