This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/29573: ICE after parse error in template argument
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Simon Martin <simartin at users dot sourceforge dot net>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Dec 2006 19:37:16 -0800
- Subject: Re: [PATCH] Fix PR c++/29573: ICE after parse error in template argument
- References: <200611010011.49642.simartin@users.sourceforge.net>
Simon Martin wrote:
> Hi all.
>
> Currently, the following invalid snippet triggers a segmentation fault:
>
> === cut here ===
> template<int> struct A {};
> template<typename> struct B : A <sizeof(=)> {};
> template<typename> struct C : A <sizeof(=)> {};
Ugh. This is due to the ugly representation of compound assignment
operators in GCC; "a += b" is represented as (MODIFY_EXPR a (PLUS_EXPR
NULL NULL) b). The NOP_EXPR case you're seeing is just one example of this.
The right fix, of course, would be to do away with this bit of nonsense,
and have MODIFY_EXPRs have a separate code field for the
compound-assignment operator -- or just use MODIFY_PLUS_EXPR, if we
could spare the code space.
Anyhow, I think the right near-term fix here is to teach cp_tree_equal
that, when recurring, MODIFY_EXPR has to be handled specially. The
second operand should only be compared for its code -- but should not be
passed recursively to cp_tree_equal.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713