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: [PATCH] Fix ICE with undeclared memcmp called with long long last argument (PR middle-end/40291)


On Fri, May 29, 2009 at 5:00 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> i?86 cmpstrn* expanders don't expect to be called with wrong mode
> operands, which can happen when memcmp has implicit prototype.
> I've checked strncmp and a couple of other builtins and they are
> ok in this regard.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
> Ok for trunk/4.4?
>
> 2009-05-29 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR middle-end/40291
> ? ? ? ?* builtins.c (expand_builtin_memcmp): Convert len to sizetype
> ? ? ? ?before expansion.
>
> ? ? ? ?* gcc.c-torture/compile/pr40291.c: New test.
>
> --- gcc/builtins.c.jj ? 2009-05-21 15:59:15.000000000 +0200
> +++ gcc/builtins.c ? ? ?2009-05-29 14:43:21.000000000 +0200
> @@ -4189,7 +4189,7 @@ expand_builtin_memcmp (tree exp, rtx tar
>
> ? ? arg1_rtx = get_memory_rtx (arg1, len);
> ? ? arg2_rtx = get_memory_rtx (arg2, len);
> - ? ?arg3_rtx = expand_normal (len);
> + ? ?arg3_rtx = expand_normal (fold_convert (sizetype, len));

shouldn't that be size_type_node?  Why do we register the function with
the wrong/missing prototype as builtin at all?

Richard.

>
> ? ? /* Set MEM_SIZE as appropriate. ?*/
> ? ? if (GET_CODE (arg3_rtx) == CONST_INT)
> --- gcc/testsuite/gcc.c-torture/compile/pr40291.c.jj ? ?2009-05-29 14:56:55.000000000 +0200
> +++ gcc/testsuite/gcc.c-torture/compile/pr40291.c ? ? ? 2009-05-29 14:57:11.000000000 +0200
> @@ -0,0 +1,7 @@
> +/* PR middle-end/40291 */
> +
> +int
> +foo (void *x, char *y, unsigned long long z)
> +{
> + ?return memcmp (x, y, z);
> +}
>
> ? ? ? ?Jakub
>


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