This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 23/25] [GDBserver] Convert amd64-linux target descriptions
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Wed, 28 Jun 2017 20:00:41 +0100
- Subject: Re: [PATCH 23/25] [GDBserver] Convert amd64-linux target descriptions
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5AEE77D0C5
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5AEE77D0C5
- References: <1497256916-4958-1-git-send-email-yao.qi@linaro.org> <1497256916-4958-24-git-send-email-yao.qi@linaro.org>
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