This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/69496 (ICE on VLA in constexpr function)
- From: Martin Sebor <msebor at gmail dot com>
- To: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Tue, 26 Jan 2016 20:58:06 -0700
- Subject: Re: C++ PATCH for c++/69496 (ICE on VLA in constexpr function)
- Authentication-results: sourceware.org; auth=none
- References: <20160126230246 dot GO25528 at redhat dot com>
On 01/26/2016 04:02 PM, Marek Polacek wrote:
The (invalid) testcase was causing an ICE because we were passing the result
of array_type_nelts_top immediately into tree_int_cst_lt, but for VLAs, the
result doesn't have to be a constant. Fixed by evaluating the bound of the
array so that we're able to give a proper out-of-bounds diagnostics. And the
VERIFY_CONSTANT should ensure that if the array bound couldn't be reduced to
a constant, we bail out rather than evoke an ICE.
Wow, you are quick! :)
I wonder if it might be better to instead reject VLAs in constexpr
functions altogether. Not because they're not in C++, but because
C (or gcc) doesn't allow them to be initialized (and so accepting
an initialized VLA is a g++ extension of an extension), and
because in constexpr functions they are rejected without
initialization just like other uninitialized variables.
FWIW, it seems to me the fewer extensions we support the less risk
of something going wrong because of unforeseen interactions with
other features.
Martin