Bug in expand_builtin_sprintf

Jakub Jelinek jakub@redhat.com
Wed Oct 10 07:54:00 GMT 2007


On Wed, Oct 10, 2007 at 08:46:44AM +0100, Heikki Linnakangas wrote:
> Kaveh R. GHAZI wrote:
> > On Mon, 8 Oct 2007, Heikki Linnakangas wrote:
> > 
> >> I think there's a small bug in expand_builtin_sprintf in trunk,
> >> introduced by commit 122018. Fix below:
> >>
> >> Index: builtins.c
> >> ===================================================================
> >> --- builtins.c  (revision 129124)
> >> +++ builtins.c  (working copy)
> >> @@ -5449,7 +5449,7 @@
> >>    dest = CALL_EXPR_ARG (exp, 0);
> >>    if (! POINTER_TYPE_P (TREE_TYPE (dest)))
> >>      return NULL_RTX;
> >> -  fmt = CALL_EXPR_ARG (exp, 0);
> >> +  fmt = CALL_EXPR_ARG (exp, 1);
> >>    if (! POINTER_TYPE_P (TREE_TYPE (fmt)))
> >>      return NULL_RTX;
> >>
> > 
> > Testcase please?
> 
> I don't have one, unfortunately. I spotted this by looking at the code.
> I believe the only consequence is that the simplifications are never
> done in expand_builtin_sprintf.

I guess the reproducer would need to make the fmt string visible to
fold_builtin only during loop optimizations or later (certainly after fab
pass) and then expand_builtin_sprintf could do this optimization.

	Jakub



More information about the Gcc-patches mailing list