This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Quash undefined behavior in ipa-inline-analysis.c
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Martin Jambor <mjambor at suse dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 Aug 2013 00:47:34 +0200
- Subject: Re: [PATCH] Quash undefined behavior in ipa-inline-analysis.c
- References: <20130813122049 dot GQ17022 at redhat dot com>
> When doing bootstrap with -fsanitize=undefined, I noticed undefined
> behavior in this file. We basically do 1 << 32, since NUM_CONDITIONS
> is #defined to 32, which is not defined. I admit I didn't followed
> the algorithm at all, but this patch passed bootstrap + regtesting
> on x86_64-linux. So, ok for trunk?
>
> 2013-08-13 Marek Polacek <polacek@redhat.com>
>
> * ipa-inline-analysis.c (add_clause): Avoid undefined behavior
> when shifting integer.
OK, thanks!
Honza
>
> --- gcc/ipa-inline-analysis.c.mp 2013-08-13 14:07:48.632662047 +0200
> +++ gcc/ipa-inline-analysis.c 2013-08-13 14:08:16.728770973 +0200
> @@ -337,7 +337,7 @@ add_clause (conditions conditions, struc
> and thus there is no point for looking for them. */
> if (cc1->code == CHANGED || cc1->code == IS_NOT_CONSTANT)
> continue;
> - for (c2 = c1 + 1; c2 <= NUM_CONDITIONS; c2++)
> + for (c2 = c1 + 1; c2 < NUM_CONDITIONS; c2++)
> if (clause & (1 << c2))
> {
> condition *cc1 =
>
> Marek