This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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: [PATCH]: Change CONST_CAST macro to accept a TYPE argument


On Mon, Sep 03, 2007 at 10:05:58AM +0200, Paolo Bonzini wrote:
> 
> >So you couldn't issue the above statement because TREE_STRING_POINTER's
> >are not generally writable.  Here, we know that it is safe because we just
> >allocated the space for it a few lines above.
> >
> >In order to write to it, you must cast away the const-ness, but doing so
> >prompts warnings from -Wcast-qual, hence the need for the CONST_CAST().
> 
> Or, you can just write
> 
>   memcpy (s->string.str, str, len);
>   s->string.str[len] = '\0';
> 
> This kind of bypassing the checks already happens e.g. in build_vl_exp_stat.

Yeah.  Especially when build_string already uses these implementation details
a few lines before that:
length = len + offsetof (struct tree_string, str) + 1;
and
memset (s, 0, sizeof (struct tree_common));
So, if STRING_CST tree layout changes, build_string will need changing
anyway.

	Jakub


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