This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [tree-ssa] Optimize reads from constant strings


On Thu, Aug 14, 2003 at 09:32:08AM -0600, law@redhat.com wrote:
> + 	if (string
> + 	    && TREE_CODE (string) == STRING_CST
> + 	    && TREE_CODE (index) == INTEGER_CST
> + 	    && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0)
> + 	  return build_int_2 ((TREE_STRING_POINTER (string)
> + 			       [TREE_INT_CST_LOW (index)]), 0);

Don't you need to check the type of the string as well?
Otherwise won't you do the wrong thing with

void foo ()
{
  if (L"\u1234"[0] != L'\u1234')
    abort ();
}

Although, I would think we ought to be able to use link_error
here -- if we don't optimize this we should.


r~


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