[PATCH]: Change CONST_CAST macro to accept a TYPE argument

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Sun Sep 2 22:27:00 GMT 2007


> > +  memcpy (CONST_CAST (char *, TREE_STRING_POINTER (s)), str, len);
> > +  ((char *) CONST_CAST (char *, TREE_STRING_POINTER (s)))[len] = '\0';
> 
> I'm sure the cast to (char *) in the last line is not needed.

I'm sure I'm missing something here, but why do we need all that complexity
on *either* of those lines?  It's *so much* harder to see at a glance
what's going on. 

If I take a quick look at that line, CONST_CAST seems to be almost as
important as TREE_STRING_POINTER to the eye, but of course it isn't.

If we can no longer write:

	TREE_STRING_POINTER (s)[len] = '\0';

I, for one, would *really* like to understand why.  The above is the logical
thing to write, is the easiest to read, and it's obvious at a glance what's
going on.  If we can't write that, perhaps we're doing something wrong.

The memcpy example seems even worse to me: you have to look much too
closely to be able to rapidly pick out which the args are here.



More information about the Gcc-patches mailing list