This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Reject too large string literals (PR middle-end/87854)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, Jason Merrill <jason at redhat dot com>, Nathan Sidwell <nathan at acm dot org>, <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 16 Nov 2018 17:34:59 +0000
- Subject: Re: [PATCH] Reject too large string literals (PR middle-end/87854)
- References: <20181116084325.GD11625@tucnak>
On Fri, 16 Nov 2018, Jakub Jelinek wrote:
> Hi!
>
> Both C and C++ FE diagnose arrays larger than half of the address space:
> /tmp/1.c:1:6: error: size of array ‘a’ is too large
> char a[__SIZE_MAX__ / 2 + 1];
> ^
> because one can't do pointer arithmetics on them. But we don't have
> anything similar for string literals. As internally we use host int
> as TREE_STRING_LENGTH, this is relevant to targets that have < 32-bit
> size_t only.
>
> The following patch adds that diagnostics and truncates the string literals.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux and tested with
> a cross to avr. I'll defer adjusting testcases to the maintainers of 16-bit
> ports. From the PR it seems gcc.dg/concat2.c, g++.dg/parse/concat1.C and
> pr46534.c tests are affected.
>
> Ok for trunk?
OK with me. I'd hope at least one test (existing or new) would actually
test the new diagnostic on 16-bit systems, rather than just those tests
being disabled for affected platforms.
--
Joseph S. Myers
joseph@codesourcery.com