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 undefined behavior in x86_64 backend (PR target/61656)


> Hi!
> 
> As mentioned in the PR, if bit_offset is not zero, subclasses array
> may contain for unions more entries than classes array.  We are going
> to ignore the extra entries, because we only check the ones below words,
> but as classes[words] and above is uninitialized, this triggers undefined
> behavior.  merge_classes seems to be a const function, so the patch should
> not affect code generation in any way.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and
> 4.9.2?)?
> 
> 2014-07-11  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR target/61656
> 	* config/i386/i386.c (classify_argument): Don't merge classes above
> 	number of words.
OK,
thanks!
Honza
> 
> --- gcc/config/i386/i386.c.jj	2014-07-09 10:41:18.000000000 +0200
> +++ gcc/config/i386/i386.c	2014-07-11 10:23:04.276634260 +0200
> @@ -6581,7 +6581,7 @@ classify_argument (enum machine_mode mod
>  					   bit_offset);
>  		  if (!num)
>  		    return 0;
> -		  for (i = 0; i < num; i++)
> +		  for (i = 0; i < num && i < words; i++)
>  		    classes[i] = merge_classes (subclasses[i], classes[i]);
>  		}
>  	    }
> 
> 	Jakub


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