gas pointer to int and vice versa

Jan Beulich jbeulich@suse.com
Wed Jul 9 05:48:34 GMT 2025


On 09.07.2025 01:53, Alan Modra wrote:
> This series of patches is aimed at updating the gas code base to be a
> little more modern.  In particular lots of casts are present from the
> K&R days when C lacked void* and function prototypes.
> 
> Use "intptr_t" or "uintptr_t" for these conversions, not "long" which
> is wrong on LLP64 systems, or "size_t" which is better but still not
> the correct type.
> 
> 	* config/tc-alpha.c (emit_ldXu, emit_ldX, emit_uldXu, emit_uldX),
> 	(emit_stX, emit_ustX, emit_sextX): Use correct type when
> 	converting vlgsize pointer to in.  Use "int" rather than
> 	"long" for result.
> 	* config/tc-ia64.c (generate_unwind_image): Use intptr_t cast
> 	when passing personality_routine to frag_var.
> 	* config/tc-ppc.c (ppc_frob_symbol <coff>): Use uintptr_t cast
> 	when converting symbol pointer to valueT.
> 	* config/tc-v850.c (md_assemble): Use intptr_t cast when
> 	loading integer opindex.
> 
> --- a/gas/config/tc-alpha.c
> +++ b/gas/config/tc-alpha.c
> @@ -2262,7 +2262,7 @@ emit_ldXu (const expressionS *tok,
>  	   const void * vlgsize)
>  {
>    if (alpha_target & AXP_OPCODE_BWX)
> -    emit_ir_load (tok, ntok, ldXu_op[(long) vlgsize]);
> +    emit_ir_load (tok, ntok, ldXu_op[(intptr_t) vlgsize]);

Here and elsewhere - can the array indexes legitimately be negative?
Presumably not, so perhaps uintptr_t would be the better type to use?

Jan


More information about the Binutils mailing list