[antlr-interest] [PATCH] ANTLR C++ RefAST operator=

aliguori123 ajl13 at bellatlantic.net
Fri Feb 1 17:48:10 PST 2002

GDB + C++ + -O2 == Major Headache...

I am still not sure exactly the depth of this and if I was just doing
some very bad things but I ran into a few infinite loops because the
operator='s are not checking for self assignment.  

While I'm not sure if I ran into this because my code was horribly
messed up, I know that reference counted objects have to check for
self assignment :)  I've made that mistake all too often.

Enclosed is a patch against 2.7.1 (the problem still exists in

I am not sure how to submit patchs/bug reports or if there is a
separate maintainer of the C++ lib so I apologize if this is the wrong
place for this.

I am really loving ANTLR though!  Even though I spent a few hours
tracking down some nasty bugs, I more than saved it with the tree

Anthony Liguori

2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/antlr/ASTRefCount.hpp
antlr-2.7.1-al/lib/cpp/antlr/ASTRefCount.hpp Page 1

>         static bool compareRef(const ASTRef* lhs, const AST* rhs);
>                 if (ASTRef::compareRef(ref, other)) return *this;
> 	        if (this == &other) return *this;
 2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/antlr/RefCount.hpp
antlr-2.7.1-al/lib/cpp/antlr/RefCount.hpp Page 1

> 	        if (this == &other) return *this;
 2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/src/ASTRefCount.cpp
antlr-2.7.1-al/lib/cpp/src/ASTRefCount.cpp Page 1

> bool ASTRef::compareRef(const ASTRef* lhs, const AST* rhs)
> {
>   return (lhs == (rhs ? rhs->ref : 0));
> }

<-- END PATCH -->


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list