This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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 23/25] [GDBserver] Convert amd64-linux target descriptions


On 06/12/2017 09:41 AM, Yao Qi wrote:
> +static const struct target_desc *amd64_tdescs[X86_TDESC_LAST] = { };
> +static const struct target_desc *x32_tdescs[X86_TDESC_LAST] = { };
> +


> +
> +  if (is_x32)
> +    tdesc = (struct target_desc **) &x32_tdescs[idx];
> +  else
> +    tdesc = (struct target_desc **) &amd64_tdescs[idx];
> +
> +  if (*tdesc == NULL)
> +    {
> +      *tdesc = new target_desc ();


You can't cast away constness of really-const objects and
write to them.  The compiler is free to place the array
in read-only storage.  If this doesn't crash at run time,
it's sheer luck.

Thanks,
Pedro Alves


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