This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Fix PR c++/29573: ICE after parse error in template argument


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


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