This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c++/35652 [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: Manuel López-Ibáñez <lopezibanez at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Paolo Bonzini <bonzini at gnu dot org>
- Date: Fri, 27 Mar 2009 08:38:04 -0700
- Subject: Re: PR c++/35652 [4.2/4.3/4.4 Regression] offset warning should be given in the front-end
- References: <6c33472e0811030736i272ea3a9r996e4b5a5fd3b3c7@mail.gmail.com> <6c33472e0902051953p6153aba7se1d5c9200fb25c4a@mail.gmail.com> <20090327144325.GA25100@lucon.org> <Pine.LNX.4.64.0903271511050.26876@digraph.polyomino.org.uk>
On Fri, Mar 27, 2009 at 8:17 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Fri, 27 Mar 2009, H.J. Lu wrote:
>
>> On Fri, Feb 06, 2009 at 04:53:10AM +0100, Manuel López-Ibáñez wrote:
>> > + ? ? 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));
>> > + ? }
>> > + ? ?}
>> > +
>>
>> tree_low_cst returns HOST_WIDE_INT. We need HOST_WIDE_INT_PRINT_DEC
>> insted of %ld. I am checking in this patch.
>
> Using HOST_WIDE_INT_PRINT_DEC is wrong here - it won't work with
> translation (the expansion may be different for different hosts, but only
> one string goes in the .pot file) and is a printf format not necessarily
> one acceptable to the diagnostic printers (on Windows hosts it may be
> %I64d, which Windows printf handles and the pretty printers don't). ?You
> should use %wd here, which the pretty printers handle internally.
>
I am checking in this patch.
Thanks.
--
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 145111)
+++ ChangeLog (working copy)
@@ -1,5 +1,10 @@
2009-03-27 H.J. Lu <hongjiu.lu@intel.com>
+ * c-common.c (pointer_int_sum): Use %wd on return from
+ tree_low_cst.
+
+2009-03-27 H.J. Lu <hongjiu.lu@intel.com>
+
* c-common.c (pointer_int_sum): Use HOST_WIDE_INT_PRINT_DEC
on return from tree_low_cst.
Index: c-common.c
===================================================================
--- c-common.c (revision 145111)
+++ c-common.c (working copy)
@@ -3315,8 +3315,8 @@ pointer_int_sum (location_t location, en
offset = offset + tree_low_cst (intop, 0);
if (offset < 0 || offset > max)
- warning_at (location, 0, "offset %<" HOST_WIDE_INT_PRINT_DEC
- "%> outside bounds of constant string",
+ warning_at (location, 0,
+ "offset %<%wd%> outside bounds of constant string",
tree_low_cst (intop, 0));
}
}