public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35652]  New: Location information incorrect on string bounds warning
@ 2008-03-20 21:07 simon_baldwin at yahoo dot com
  2008-03-21 12:50 ` [Bug c++/35652] " rguenth at gcc dot gnu dot org
                   ` (37 more replies)
  0 siblings, 38 replies; 40+ messages in thread
From: simon_baldwin at yahoo dot com @ 2008-03-20 21:07 UTC (permalink / raw)
  To: gcc-bugs

The following demonstrates a location error in a string bounds warning message:

$ cat /tmp/c.cc
#include <string>
int main() {
  // blank line padding, could also be code...
  //
  //
  //
  //
  //
  //
  //
  //
  //
  std::string s = "";
  s += 'x' + "y";  // bogus
}

$ g++ -O2 -c /tmp/c.cc
/tmp/c.cc: In function 'int main()':
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/tmp/c.cc:2: warning: offset outside bounds of constant string
/.../i686-unknown-linux-gnu/include/c++/4.3.0/bits/char_traits.h:262: warning:
offset outside bounds of constant string
/.../i686-unknown-linux-gnu/include/c++/4.3.0/bits/char_traits.h:262: warning:
offset outside bounds of constant string

The erroneous line is line 14, but g++ reports the problem (multiple times) at
line 2 and in an STL header file.  The same behavior occurs in g++ 4.2.1,
4.1.1, 4.0.3, and 4.0.2.  It does not occur in gcc 3.4.5.

Also, there is no warning emitted with -O0, for some reason.


-- 
           Summary: Location information incorrect on string bounds warning
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: simon_baldwin at yahoo dot com


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
@ 2008-03-21 12:50 ` rguenth at gcc dot gnu dot org
  2008-03-21 12:53 ` [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-21 12:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-03-21 12:49 -------
The warning happens when for example constant propagation tries to optimize
the read from the constant string and calls builtins.c:c_strlen which
produces this warning.  As that warning doesn't specify any location the
current source location is used which is bogus for a warning from the
middle-end.

What we see in the IL that causes this is:

<bb 4>:
  D.12603_7 = append (&s, &"y"[120]);

which is because 'x' + "y" is the same as "y"['x'].

We should avoid re-constructing these out-of-bounds array accesses.

Note that the warning appears multiple times since &"y"[120] is a constant
that is replicated all over the IL and thus present multiple times.
If c_strlen would just return 0 in these cases after warning once that
would fix the issue as well (and it can validly do so, as the code invokes
undefined behavior).


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic, wrong-code
      Known to fail|                            |4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2008-03-21 12:49:51
               date|                            |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
  2008-03-21 12:50 ` [Bug c++/35652] " rguenth at gcc dot gnu dot org
@ 2008-03-21 12:53 ` rguenth at gcc dot gnu dot org
  2008-03-21 13:02 ` rguenth at gcc dot gnu dot org
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-21 12:53 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |3.4.6
           Priority|P3                          |P2
            Summary|Location information        |[4.1/4.2/4.3/4.4 Regression]
                   |incorrect on string bounds  |Location information
                   |warning                     |incorrect on string bounds
                   |                            |warning
   Target Milestone|---                         |4.1.3


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
  2008-03-21 12:50 ` [Bug c++/35652] " rguenth at gcc dot gnu dot org
  2008-03-21 12:53 ` [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
@ 2008-03-21 13:02 ` rguenth at gcc dot gnu dot org
  2008-04-26 17:01 ` simonb at gcc dot gnu dot org
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-21 13:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-03-21 13:01 -------
With that approach we'd get

./cc1plus -quiet -O /tmp/t.ii 
t.C: In function 'int main()':
t.C:2: warning: offset outside bounds of constant string

thus a single warning still with wrong location information (at this point we
cannot do better here).

IMHO the warning belongs in the frontend and the warning code from c_strlen
should be deleted.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (2 preceding siblings ...)
  2008-03-21 13:02 ` rguenth at gcc dot gnu dot org
@ 2008-04-26 17:01 ` simonb at gcc dot gnu dot org
  2008-04-26 17:22 ` simon_baldwin at yahoo dot com
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: simonb at gcc dot gnu dot org @ 2008-04-26 17:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from simonb at gcc dot gnu dot org  2008-04-26 17:00 -------
Subject: Bug 35652

Author: simonb
Date: Sat Apr 26 16:59:38 2008
New Revision: 134714

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134714
Log:
       PR c/35652
       * builtins.c (c_strlen): Suppressed multiple warnings that can occur
       with propagated string constants.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (3 preceding siblings ...)
  2008-04-26 17:01 ` simonb at gcc dot gnu dot org
@ 2008-04-26 17:22 ` simon_baldwin at yahoo dot com
  2008-04-26 20:53 ` rguenth at gcc dot gnu dot org
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: simon_baldwin at yahoo dot com @ 2008-04-26 17:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from simon_baldwin at yahoo dot com  2008-04-26 17:21 -------
Closing.  Location information may still not be accurate, but duplicate
warnings are gone.


-- 

simon_baldwin at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (4 preceding siblings ...)
  2008-04-26 17:22 ` simon_baldwin at yahoo dot com
@ 2008-04-26 20:53 ` rguenth at gcc dot gnu dot org
  2008-07-04 22:41 ` [Bug c++/35652] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-26 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-04-26 20:52 -------
Re-opening.  Only parts of the problem is fixed and it is still a regression
on all branches.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|RESOLVED                    |REOPENED
           Keywords|wrong-code                  |
         Resolution|FIXED                       |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] Location information incorrect on string bounds warning
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (5 preceding siblings ...)
  2008-04-26 20:53 ` rguenth at gcc dot gnu dot org
@ 2008-07-04 22:41 ` jsm28 at gcc dot gnu dot org
  2008-10-30 22:46 ` [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end manu at gcc dot gnu dot org
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jsm28 at gcc dot gnu dot org  2008-07-04 22:40 -------
Closing 4.1 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2/4.3/4.4 Regression]|[4.2/4.3/4.4 Regression]
                   |Location information        |Location information
                   |incorrect on string bounds  |incorrect on string bounds
                   |warning                     |warning
   Target Milestone|4.1.3                       |4.2.5


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (6 preceding siblings ...)
  2008-07-04 22:41 ` [Bug c++/35652] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2008-10-30 22:46 ` manu at gcc dot gnu dot org
  2008-11-01 17:46 ` manu at gcc dot gnu dot org
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-10-30 22:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from manu at gcc dot gnu dot org  2008-10-30 22:44 -------
The location info seems to be fixed in mainline. Nonetheless, I agree
completely with Richard. This warning belongs in the front-end. Moreover we
fail to diagnose:

const char *s = 'x' + "y";

in both C and C++. Also, this warning does not really requires -O2, so it
should work at -O0 too.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
            Summary|[4.2/4.3/4.4 Regression]    |[4.2/4.3/4.4 Regression]
                   |Location information        |offset warning should be
                   |incorrect on string bounds  |given in the front-end
                   |warning                     |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (7 preceding siblings ...)
  2008-10-30 22:46 ` [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end manu at gcc dot gnu dot org
@ 2008-11-01 17:46 ` manu at gcc dot gnu dot org
  2008-11-02 12:22 ` rguenther at suse dot de
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-11-01 17:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from manu at gcc dot gnu dot org  2008-11-01 17:44 -------
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?


@@ -3322,10 +3323,36 @@ pointer_int_sum (enum tree_code resultco

   /* Create the sum or difference.  */
   if (resultcode == MINUS_EXPR)
     intop = fold_build1 (NEGATE_EXPR, sizetype, intop);

+
+  if (TREE_CODE (intop) == INTEGER_CST)
+    {
+      tree offset_node;
+      tree string_cst = string_constant (ptrop, &offset_node);
+
+      if (string_cst != 0
+         && !(offset_node && TREE_CODE (offset_node) != INTEGER_CST))
+       {
+         HOST_WIDE_INT max = TREE_STRING_LENGTH (string_cst) - 1;
+         HOST_WIDE_INT offset;
+         if (offset_node == 0)
+           offset = 0;
+         else if (! host_integerp (offset_node, 0))
+           offset = -1;
+         else
+           offset = tree_low_cst (offset_node, 0);
+
+         offset = offset + tree_low_cst (intop, 0);
+         if (offset < 0 || offset > max)
+           warning_at (location, 0,
+                       "offset %<%ld%> outside bounds of constant string",
+                       tree_low_cst (intop, 0));
+       }
+    }
+
   ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop);

   fold_undefer_and_ignore_overflow_warnings ();

   return ret;


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (8 preceding siblings ...)
  2008-11-01 17:46 ` manu at gcc dot gnu dot org
@ 2008-11-02 12:22 ` rguenther at suse dot de
  2008-11-02 12:54 ` manu at gcc dot gnu dot org
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenther at suse dot de @ 2008-11-02 12:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenther at suse dot de  2008-11-02 12:20 -------
Subject: Re:  [4.2/4.3/4.4 Regression] offset warning should
 be given in the front-end

On Sat, 1 Nov 2008, manu at gcc dot gnu dot org wrote:

> ------- Comment #8 from manu at gcc dot gnu dot org  2008-11-01 17:44 -------
> 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 ...

> 
> @@ -3322,10 +3323,36 @@ pointer_int_sum (enum tree_code resultco
> 
>    /* Create the sum or difference.  */
>    if (resultcode == MINUS_EXPR)
>      intop = fold_build1 (NEGATE_EXPR, sizetype, intop);
> 
> +
> +  if (TREE_CODE (intop) == INTEGER_CST)
> +    {
> +      tree offset_node;
> +      tree string_cst = string_constant (ptrop, &offset_node);
> +
> +      if (string_cst != 0
> +         && !(offset_node && TREE_CODE (offset_node) != INTEGER_CST))
> +       {
> +         HOST_WIDE_INT max = TREE_STRING_LENGTH (string_cst) - 1;

... the -1 is wrong here.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (9 preceding siblings ...)
  2008-11-02 12:22 ` rguenther at suse dot de
@ 2008-11-02 12:54 ` manu at gcc dot gnu dot org
  2008-11-02 13:07   ` Andrew Thomas Pinski
  2008-11-02 13:04 ` rguenth at gcc dot gnu dot org
                   ` (26 subsequent siblings)
  37 siblings, 1 reply; 40+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-11-02 12:54 UTC (permalink / raw)
  To: gcc-bugs



------- 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).

> > 
> > @@ -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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (10 preceding siblings ...)
  2008-11-02 12:54 ` manu at gcc dot gnu dot org
@ 2008-11-02 13:04 ` rguenth at gcc dot gnu dot org
  2008-11-02 13:09 ` pinskia at gmail dot com
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-02 13:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2008-11-02 13:02 -------
I'm not sure.  Does TREE_STRING_LENGTH in the particular case include the
NULL character?  Does sizeof(str) include the NULL character?

In principle it is allowed to have a pointer point one after the last element
of an array.  That IMHO would include the NULL character, so for "foo"
pointing to "foo" + 4 would be ok.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-11-02 12:54 ` manu at gcc dot gnu dot org
@ 2008-11-02 13:07   ` Andrew Thomas Pinski
  0 siblings, 0 replies; 40+ messages in thread
From: Andrew Thomas Pinski @ 2008-11-02 13:07 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



Sent from my iPhone

On Nov 2, 2008, at 4:53 AM, "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org 
 > 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
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (11 preceding siblings ...)
  2008-11-02 13:04 ` rguenth at gcc dot gnu dot org
@ 2008-11-02 13:09 ` pinskia at gmail dot com
  2009-02-03 16:40 ` bonzini at gnu dot org
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: pinskia at gmail dot com @ 2008-11-02 13:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pinskia at gmail dot com  2008-11-02 13:07 -------
Subject: Re:  [4.2/4.3/4.4 Regression] offset warning should be given in the
front-end



Sent from my iPhone

On Nov 2, 2008, at 4:53 AM, "manu at gcc dot gnu dot org"
<gcc-bugzilla@gcc.gnu.org 
 > 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
>


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (12 preceding siblings ...)
  2008-11-02 13:09 ` pinskia at gmail dot com
@ 2009-02-03 16:40 ` bonzini at gnu dot org
  2009-02-08 15:46 ` manu at gcc dot gnu dot org
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: bonzini at gnu dot org @ 2009-02-03 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from bonzini at gnu dot org  2009-02-03 16:40 -------
I agree that the patch is correct *without* the -1, so... ping :)


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (13 preceding siblings ...)
  2009-02-03 16:40 ` bonzini at gnu dot org
@ 2009-02-08 15:46 ` manu at gcc dot gnu dot org
  2009-03-27  7:17 ` andreasmeier80 at gmx dot de
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-02-08 15:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from manu at gcc dot gnu dot org  2009-02-08 15:46 -------
Patch: http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00285.html


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2009-
                   |                            |02/msg00285.html
           Keywords|                            |patch
   Last reconfirmed|2008-03-21 12:49:51         |2009-02-08 15:46:08
               date|                            |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (14 preceding siblings ...)
  2009-02-08 15:46 ` manu at gcc dot gnu dot org
@ 2009-03-27  7:17 ` andreasmeier80 at gmx dot de
  2009-03-27 12:53 ` hjl at gcc dot gnu dot org
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: andreasmeier80 at gmx dot de @ 2009-03-27  7:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from andreasmeier80 at gmx dot de  2009-03-27 07:16 -------
Approved here: http://gcc.gnu.org/ml/gcc-patches/2009-03/msg01079.html


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (15 preceding siblings ...)
  2009-03-27  7:17 ` andreasmeier80 at gmx dot de
@ 2009-03-27 12:53 ` hjl at gcc dot gnu dot org
  2009-03-27 14:31 ` [Bug c++/35652] [4.2/4.3 " dominiq at lps dot ens dot fr
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: hjl at gcc dot gnu dot org @ 2009-03-27 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from hjl at gcc dot gnu dot org  2009-03-27 12:53 -------
Subject: Bug 35652

Author: hjl
Date: Fri Mar 27 12:52:52 2009
New Revision: 145102

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145102
Log:
gcc/

2009-03-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/35652
        * builtins.h (c_strlen): Do not warn here.
        * c-typeck.c (build_binary_op): Adjust calls to pointer_int_sum.
        * c-common.c (pointer_int_sum): Take an explicit location.
        Warn about offsets out of bounds.
        * c-common.h (pointer_int_sum): Adjust declaration.

gcc/cp/

2009-03-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/35652
        * typeck.c (cp_pointer_sum): Adjust call to pointer_int_sum.

gcc/testsuite/

2009-03-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/35652
        * gcc.dg/pr35652.C: New.
        * g++.dg/warn/pr35652.C: New.
        * gcc.dg/format/plus-1.c: Adjust message.

Added:
    trunk/gcc/testsuite/g++.dg/warn/pr35652.C
    trunk/gcc/testsuite/gcc.dg/pr35652.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/format/plus-1.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (16 preceding siblings ...)
  2009-03-27 12:53 ` hjl at gcc dot gnu dot org
@ 2009-03-27 14:31 ` dominiq at lps dot ens dot fr
  2009-03-27 14:34 ` rguenth at gcc dot gnu dot org
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-03-27 14:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from dominiq at lps dot ens dot fr  2009-03-27 14:30 -------
The commit in comment #16 breaks bootstrap on *-darwin9:

...
cc1: warnings being treated as errors
../../gcc-4.4-work/gcc/c-common.c: In function 'pointer_int_sum':
../../gcc-4.4-work/gcc/c-common.c:3320: error: format '%ld' expects type 'long
int', but argument 4 has type 'long long int'
...


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (17 preceding siblings ...)
  2009-03-27 14:31 ` [Bug c++/35652] [4.2/4.3 " dominiq at lps dot ens dot fr
@ 2009-03-27 14:34 ` rguenth at gcc dot gnu dot org
  2009-03-27 14:44 ` dominiq at lps dot ens dot fr
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-27 14:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from rguenth at gcc dot gnu dot org  2009-03-27 14:34 -------
If this isn't resolved quickly please open a bugreport for this.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (18 preceding siblings ...)
  2009-03-27 14:34 ` rguenth at gcc dot gnu dot org
@ 2009-03-27 14:44 ` dominiq at lps dot ens dot fr
  2009-03-27 14:50 ` dominiq at lps dot ens dot fr
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-03-27 14:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from dominiq at lps dot ens dot fr  2009-03-27 14:44 -------
> If this isn't resolved quickly please open a bugreport for this.

I'll do it.  This is a recurrent issue due to maintainers not using the -Werror
in their tests.
Unfortunately I don't remember how such failures have been fixed in the past (a
cast to long int?).


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (19 preceding siblings ...)
  2009-03-27 14:44 ` dominiq at lps dot ens dot fr
@ 2009-03-27 14:50 ` dominiq at lps dot ens dot fr
  2009-03-27 15:13 ` dominiq at lps dot ens dot fr
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-03-27 14:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from dominiq at lps dot ens dot fr  2009-03-27 14:50 -------
Currently testing the patch in
http://gcc.gnu.org/ml/gcc-patches/2009-03/msg01377.html.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (20 preceding siblings ...)
  2009-03-27 14:50 ` dominiq at lps dot ens dot fr
@ 2009-03-27 15:13 ` dominiq at lps dot ens dot fr
  2009-03-30 13:51 ` jakub at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-03-27 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from dominiq at lps dot ens dot fr  2009-03-27 15:13 -------
The failure reported in comment #17 has been fixed by revision 145109.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (21 preceding siblings ...)
  2009-03-27 15:13 ` dominiq at lps dot ens dot fr
@ 2009-03-30 13:51 ` jakub at gcc dot gnu dot org
  2009-03-30 17:42 ` jakub at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-03-30 13:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from jakub at gcc dot gnu dot org  2009-03-30 13:51 -------
What exact regression was fixed by the
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145102
commit?


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (22 preceding siblings ...)
  2009-03-30 13:51 ` jakub at gcc dot gnu dot org
@ 2009-03-30 17:42 ` jakub at gcc dot gnu dot org
  2009-03-31 13:11 ` espindola at google dot com
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-03-30 17:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #23 from jakub at gcc dot gnu dot org  2009-03-30 17:42 -------
Subject: Bug 35652

Author: jakub
Date: Mon Mar 30 17:42:27 2009
New Revision: 145308

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145308
Log:
Revert PR c++/35652

Removed:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/warn/pr35652.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr35652.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/builtins.c
    branches/gcc-4_4-branch/gcc/c-common.c
    branches/gcc-4_4-branch/gcc/c-common.h
    branches/gcc-4_4-branch/gcc/c-typeck.c
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/typeck.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/format/plus-1.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (23 preceding siblings ...)
  2009-03-30 17:42 ` jakub at gcc dot gnu dot org
@ 2009-03-31 13:11 ` espindola at google dot com
  2009-03-31 13:12 ` espindola at google dot com
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: espindola at google dot com @ 2009-03-31 13:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #24 from espindola at google dot com  2009-03-31 13:11 -------
Created an attachment (id=17571)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17571&action=view)
testcase

original .c testcase


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.2/4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (24 preceding siblings ...)
  2009-03-31 13:11 ` espindola at google dot com
@ 2009-03-31 13:12 ` espindola at google dot com
  2009-03-31 20:49 ` [Bug c++/35652] [4.3 " jsm28 at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: espindola at google dot com @ 2009-03-31 13:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #25 from espindola at google dot com  2009-03-31 13:11 -------
Created an attachment (id=17572)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17572&action=view)
preprocessed testcase


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (25 preceding siblings ...)
  2009-03-31 13:12 ` espindola at google dot com
@ 2009-03-31 20:49 ` jsm28 at gcc dot gnu dot org
  2009-04-11 17:01 ` rob1weld at aol dot com
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 20:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #26 from jsm28 at gcc dot gnu dot org  2009-03-31 20:49 -------
Closing 4.2 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3 Regression] offset |[4.3 Regression] offset
                   |warning should be given in  |warning should be given in
                   |the front-end               |the front-end
   Target Milestone|4.2.5                       |4.3.4


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (26 preceding siblings ...)
  2009-03-31 20:49 ` [Bug c++/35652] [4.3 " jsm28 at gcc dot gnu dot org
@ 2009-04-11 17:01 ` rob1weld at aol dot com
  2009-04-14 14:51 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rob1weld at aol dot com @ 2009-04-11 17:01 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]



------- Comment #27 from rob1weld at aol dot com  2009-04-11 17:01 -------
Ping: gcc version 4.5.0 20090407 trunk revision 145649
gcc_trunk/libiberty/cplus-dem.c:2651: warning: offset ‘3’ outside bounds of
constant string

Noticed while building binutils (with -Werror):
../binutils-2.19.1/bfd/elf.c: In function '_bfd_elf_print_private_bfd_data':
../binutils-2.19.1/bfd/elf.c:1236: error: offset '2' outside bounds of constant
string

Thanks,
Rob


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (27 preceding siblings ...)
  2009-04-11 17:01 ` rob1weld at aol dot com
@ 2009-04-14 14:51 ` pinskia at gcc dot gnu dot org
  2009-04-15  7:41 ` dcb314 at hotmail dot com
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-14 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #28 from pinskia at gcc dot gnu dot org  2009-04-14 14:50 -------
*** Bug 39748 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (28 preceding siblings ...)
  2009-04-14 14:51 ` pinskia at gcc dot gnu dot org
@ 2009-04-15  7:41 ` dcb314 at hotmail dot com
  2009-04-28  4:57 ` bje at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: dcb314 at hotmail dot com @ 2009-04-15  7:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #29 from dcb314 at hotmail dot com  2009-04-15 07:41 -------
(In reply to comment #27)
> Noticed while building binutils (with -Werror):
> ../binutils-2.19.1/bfd/elf.c: In function '_bfd_elf_print_private_bfd_data':
> ../binutils-2.19.1/bfd/elf.c:1236: error: offset '2' outside bounds of constant
> string

+1.

Various packages (eg gdb) use -Werror and so fail to build with 4.5
snapshot 20090409.

Would it be reasonable to switch off temporarily this warning message,
until it works more accurately ?


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (29 preceding siblings ...)
  2009-04-15  7:41 ` dcb314 at hotmail dot com
@ 2009-04-28  4:57 ` bje at gcc dot gnu dot org
  2009-08-04 12:40 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: bje at gcc dot gnu dot org @ 2009-04-28  4:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #30 from bje at gcc dot gnu dot org  2009-04-28 04:57 -------
Subject: Bug 35652

Author: bje
Date: Tue Apr 28 04:56:47 2009
New Revision: 146870

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146870
Log:
Revert:
        PR c++/35652
        2009-03-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

gcc/
        * builtins.c (c_strlen): Do not warn here.
        * c-typeck.c (build_binary_op): Adjust calls to pointer_int_sum.
        * c-common.c (pointer_int_sum): Take an explicit location.
        Warn about offsets out of bounds.
        * c-common.h (pointer_int_sum): Adjust declaration.

cp/
        * typeck.c (cp_pointer_sum): Adjust call to pointer_int_sum.

testsuite/
        * gcc.dg/pr35652.C: New.
        * g++.dg/warn/pr35652.C: New.
        * gcc.dg/format/plus-1.c: Adjust message.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/warn/pr35652.C
    trunk/gcc/testsuite/gcc.dg/format/plus-1.c
    trunk/gcc/testsuite/gcc.dg/pr35652.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (30 preceding siblings ...)
  2009-04-28  4:57 ` bje at gcc dot gnu dot org
@ 2009-08-04 12:40 ` rguenth at gcc dot gnu dot org
  2009-08-04 23:42 ` [Bug c++/35652] [4.3/4.4/4.5 " manu at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #31 from rguenth at gcc dot gnu dot org  2009-08-04 12:29 -------
GCC 4.3.4 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.4                       |4.3.5


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (31 preceding siblings ...)
  2009-08-04 12:40 ` rguenth at gcc dot gnu dot org
@ 2009-08-04 23:42 ` manu at gcc dot gnu dot org
  2009-12-20 18:09 ` jason at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-08-04 23:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #32 from manu at gcc dot gnu dot org  2009-08-04 23:42 -------
Since the patch was reverted, this is still a regression in all open branches.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|http://gcc.gnu.org/ml/gcc-  |
                   |patches/2009-               |
                   |02/msg00285.html            |
      Known to fail|4.3.0                       |4.3.0 4.4.0 4.5.0
      Known to work|3.4.6 4.4.0                 |3.4.6
   Last reconfirmed|2009-02-08 15:46:08         |2009-08-04 23:42:34
               date|                            |
            Summary|[4.3 Regression] offset     |[4.3/4.4/4.5 Regression]
                   |warning should be given in  |offset warning should be
                   |the front-end               |given in the front-end


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (32 preceding siblings ...)
  2009-08-04 23:42 ` [Bug c++/35652] [4.3/4.4/4.5 " manu at gcc dot gnu dot org
@ 2009-12-20 18:09 ` jason at gcc dot gnu dot org
  2009-12-20 18:50 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-12-20 18:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #33 from jason at gcc dot gnu dot org  2009-12-20 18:09 -------
Why was the patch reverted?


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (33 preceding siblings ...)
  2009-12-20 18:09 ` jason at gcc dot gnu dot org
@ 2009-12-20 18:50 ` jakub at gcc dot gnu dot org
  2010-02-03  5:24 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 40+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-12-20 18:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #34 from jakub at gcc dot gnu dot org  2009-12-20 18:50 -------
It was warning too much, even about if (0) code, so it broke a lot of valid
code with -Werror, including stuff like:
#include <string.h>
int f (char *s)
{
  return strcmp (s, "");
}
If a warning like this is to be done by the FE, it would need to be only queued
in the IL and emitted only if it survived at least some initial DCE.  Perhaps
in a form of an artificial __builtin_warning, or something similar.


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (34 preceding siblings ...)
  2009-12-20 18:50 ` jakub at gcc dot gnu dot org
@ 2010-02-03  5:24 ` jason at gcc dot gnu dot org
  2010-02-03 16:28 ` jason at gcc dot gnu dot org
  2010-02-03 16:29 ` jason at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-02-03  5:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|REOPENED                    |ASSIGNED
   Last reconfirmed|2009-08-04 23:42:34         |2010-02-03 05:24:16
               date|                            |


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (35 preceding siblings ...)
  2010-02-03  5:24 ` jason at gcc dot gnu dot org
@ 2010-02-03 16:28 ` jason at gcc dot gnu dot org
  2010-02-03 16:29 ` jason at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-02-03 16:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #35 from jason at gcc dot gnu dot org  2010-02-03 16:28 -------
Subject: Bug 35652

Author: jason
Date: Wed Feb  3 16:28:07 2010
New Revision: 156469

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156469
Log:
        PR c++/35652
        * builtins.c (c_strlen): Use EXPR_LOCATION in diagnostics.

Added:
    trunk/gcc/testsuite/g++.dg/warn/string1.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c


-- 


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Bug c++/35652] [4.3/4.4/4.5 Regression] offset warning should be given in the front-end
  2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
                   ` (36 preceding siblings ...)
  2010-02-03 16:28 ` jason at gcc dot gnu dot org
@ 2010-02-03 16:29 ` jason at gcc dot gnu dot org
  37 siblings, 0 replies; 40+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-02-03 16:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #36 from jason at gcc dot gnu dot org  2010-02-03 16:29 -------
Fixed for 4.5.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.3.5                       |4.5.0


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


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2010-02-03 16:29 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-20 21:07 [Bug c++/35652] New: Location information incorrect on string bounds warning simon_baldwin at yahoo dot com
2008-03-21 12:50 ` [Bug c++/35652] " rguenth at gcc dot gnu dot org
2008-03-21 12:53 ` [Bug c++/35652] [4.1/4.2/4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-03-21 13:02 ` rguenth at gcc dot gnu dot org
2008-04-26 17:01 ` simonb at gcc dot gnu dot org
2008-04-26 17:22 ` simon_baldwin at yahoo dot com
2008-04-26 20:53 ` rguenth at gcc dot gnu dot org
2008-07-04 22:41 ` [Bug c++/35652] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2008-10-30 22:46 ` [Bug c++/35652] [4.2/4.3/4.4 Regression] offset warning should be given in the front-end manu at gcc dot gnu dot org
2008-11-01 17:46 ` manu at gcc dot gnu dot org
2008-11-02 12:22 ` rguenther at suse dot de
2008-11-02 12:54 ` manu at gcc dot gnu dot org
2008-11-02 13:07   ` Andrew Thomas Pinski
2008-11-02 13:04 ` rguenth at gcc dot gnu dot org
2008-11-02 13:09 ` pinskia at gmail dot com
2009-02-03 16:40 ` bonzini at gnu dot org
2009-02-08 15:46 ` manu at gcc dot gnu dot org
2009-03-27  7:17 ` andreasmeier80 at gmx dot de
2009-03-27 12:53 ` hjl at gcc dot gnu dot org
2009-03-27 14:31 ` [Bug c++/35652] [4.2/4.3 " dominiq at lps dot ens dot fr
2009-03-27 14:34 ` rguenth at gcc dot gnu dot org
2009-03-27 14:44 ` dominiq at lps dot ens dot fr
2009-03-27 14:50 ` dominiq at lps dot ens dot fr
2009-03-27 15:13 ` dominiq at lps dot ens dot fr
2009-03-30 13:51 ` jakub at gcc dot gnu dot org
2009-03-30 17:42 ` jakub at gcc dot gnu dot org
2009-03-31 13:11 ` espindola at google dot com
2009-03-31 13:12 ` espindola at google dot com
2009-03-31 20:49 ` [Bug c++/35652] [4.3 " jsm28 at gcc dot gnu dot org
2009-04-11 17:01 ` rob1weld at aol dot com
2009-04-14 14:51 ` pinskia at gcc dot gnu dot org
2009-04-15  7:41 ` dcb314 at hotmail dot com
2009-04-28  4:57 ` bje at gcc dot gnu dot org
2009-08-04 12:40 ` rguenth at gcc dot gnu dot org
2009-08-04 23:42 ` [Bug c++/35652] [4.3/4.4/4.5 " manu at gcc dot gnu dot org
2009-12-20 18:09 ` jason at gcc dot gnu dot org
2009-12-20 18:50 ` jakub at gcc dot gnu dot org
2010-02-03  5:24 ` jason at gcc dot gnu dot org
2010-02-03 16:28 ` jason at gcc dot gnu dot org
2010-02-03 16:29 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).