Sent from my iPhone

On Nov 2, 2008, at 4:53 AM, "manu at gcc dot gnu dot org" <[EMAIL PROTECTED] > wrote:



------- Comment #10 from manu at gcc dot gnu dot org 2008-11-02 12:53 -------
(In reply to comment #9)
This is my current patch and it works in this testcase. However, it also
triggers on cases like: const char *p = str + sizeof(str)

Perhaps I am doing this at the wrong place. Any suggestions?

Keep in mind that one-after the string is ok, so ...

Do you mean one after the null character? If you have str = "abcd". Then sizeof(str) is 5 and str + sizeof(str) points outside the string. (str[4] is
the null character).

That is still well defined. Taking the address of one element past the end of the array is well defined. Just you can not derefence it.
Thanks,
Andrew Pinski




@@ -3322,10 +3323,36 @@ pointer_int_sum (enum tree_code resultco
+       {
+         HOST_WIDE_INT max = TREE_STRING_LENGTH (string_cst) - 1;

... the -1 is wrong here.


TREE_STRING_LENGTH is the size of the character array, not the string. Are you
sure it is wrong?


--


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35652

Reply via email to